mirror of
https://github.com/mudler/LocalAI.git
synced 2024-12-18 20:27:57 +00:00
fix: speedup and improve cachability of docker build of builder-sd
(#3430)
fix: speedup and improve cachability of docker build of `builder-sd` (#3430) --------- Signed-off-by: Dave Lee <dave@gray101.com>
This commit is contained in:
parent
3be71811ca
commit
300f2779e4
25
Dockerfile
25
Dockerfile
@ -263,14 +263,20 @@ EOT
|
|||||||
# In most cases, builder is the image you should be using - however, this can save build time if one just needs to copy backend-assets/grpc/stablediffusion and nothing else.
|
# In most cases, builder is the image you should be using - however, this can save build time if one just needs to copy backend-assets/grpc/stablediffusion and nothing else.
|
||||||
FROM builder-base AS builder-sd
|
FROM builder-base AS builder-sd
|
||||||
|
|
||||||
COPY . .
|
# stablediffusion does not tolerate a newer version of abseil, copy only over enough elements to build it
|
||||||
COPY .git .
|
COPY Makefile .
|
||||||
|
COPY go.mod .
|
||||||
|
COPY go.sum .
|
||||||
|
COPY backend/backend.proto ./backend/backend.proto
|
||||||
|
COPY backend/go/image/stablediffusion ./backend/go/image/stablediffusion
|
||||||
|
COPY pkg/grpc ./pkg/grpc
|
||||||
|
COPY pkg/stablediffusion ./pkg/stablediffusion
|
||||||
|
RUN git init
|
||||||
|
RUN make sources/go-stable-diffusion
|
||||||
|
RUN touch prepare-sources
|
||||||
|
|
||||||
RUN make prepare
|
# Actually build the backend
|
||||||
|
RUN GRPC_BACKENDS=backend-assets/grpc/stablediffusion make backend-assets/grpc/stablediffusion
|
||||||
|
|
||||||
# stablediffusion does not tolerate a newer version of abseil, build it first
|
|
||||||
RUN GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
|
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
###################################
|
###################################
|
||||||
@ -285,6 +291,11 @@ COPY --from=grpc /opt/grpc /usr/local
|
|||||||
# Rebuild with defaults backends
|
# Rebuild with defaults backends
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
COPY .git .
|
||||||
|
|
||||||
|
RUN make prepare
|
||||||
|
|
||||||
## Build the binary
|
## Build the binary
|
||||||
## If it's CUDA, we want to skip some of the llama-compat backends to save space
|
## If it's CUDA, we want to skip some of the llama-compat backends to save space
|
||||||
## We only leave the most CPU-optimized variant and the fallback for the cublas build
|
## We only leave the most CPU-optimized variant and the fallback for the cublas build
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mudler/LocalAI/core/schema"
|
"github.com/mudler/LocalAI/core/schema"
|
||||||
|
|
||||||
"github.com/mudler/LocalAI/pkg/grpc/proto"
|
"github.com/mudler/LocalAI/pkg/grpc/proto"
|
||||||
model "github.com/mudler/LocalAI/pkg/model"
|
"github.com/mudler/LocalAI/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ModelTranscription(audio, language string, translate bool, ml *model.ModelLoader, backendConfig config.BackendConfig, appConfig *config.ApplicationConfig) (*schema.TranscriptionResult, error) {
|
func ModelTranscription(audio, language string, translate bool, ml *model.ModelLoader, backendConfig config.BackendConfig, appConfig *config.ApplicationConfig) (*schema.TranscriptionResult, error) {
|
||||||
@ -22,16 +22,16 @@ func ModelTranscription(audio, language string, translate bool, ml *model.ModelL
|
|||||||
model.WithAssetDir(appConfig.AssetsDestination),
|
model.WithAssetDir(appConfig.AssetsDestination),
|
||||||
})
|
})
|
||||||
|
|
||||||
whisperModel, err := ml.BackendLoader(opts...)
|
transcriptionModel, err := ml.BackendLoader(opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if whisperModel == nil {
|
if transcriptionModel == nil {
|
||||||
return nil, fmt.Errorf("could not load whisper model")
|
return nil, fmt.Errorf("could not load transcription model")
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := whisperModel.AudioTranscription(context.Background(), &proto.TranscriptRequest{
|
r, err := transcriptionModel.AudioTranscription(context.Background(), &proto.TranscriptRequest{
|
||||||
Dst: audio,
|
Dst: audio,
|
||||||
Language: language,
|
Language: language,
|
||||||
Translate: translate,
|
Translate: translate,
|
||||||
|
Loading…
Reference in New Issue
Block a user