2023-08-23 23:18:58 +00:00
|
|
|
ARG GO_VERSION=1.21-bullseye
|
2023-05-30 13:53:37 +00:00
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
FROM golang:$GO_VERSION as requirements
|
2023-05-29 21:12:27 +00:00
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
ARG BUILD_TYPE
|
2023-05-29 21:12:27 +00:00
|
|
|
ARG CUDA_MAJOR_VERSION=11
|
|
|
|
ARG CUDA_MINOR_VERSION=7
|
2023-06-22 15:53:10 +00:00
|
|
|
ARG SPDLOG_VERSION="1.11.0"
|
|
|
|
ARG PIPER_PHONEMIZE_VERSION='1.0.0'
|
|
|
|
ARG TARGETARCH
|
|
|
|
ARG TARGETVARIANT
|
2023-05-29 21:12:27 +00:00
|
|
|
|
|
|
|
ENV BUILD_TYPE=${BUILD_TYPE}
|
2023-09-09 14:46:13 +00:00
|
|
|
ENV EXTERNAL_GRPC_BACKENDS="huggingface-embeddings:/build/extra/grpc/huggingface/huggingface.py,autogptq:/build/extra/grpc/autogptq/autogptq.py,bark:/build/extra/grpc/bark/ttsbark.py,diffusers:/build/extra/grpc/diffusers/backend_diffusers.py,exllama:/build/extra/grpc/exllama/exllama.py,vall-e-x:/build/extra/grpc/vall-e-x/ttsvalle.py,vllm:/build/extra/grpc/vllm/backend_vllm.py"
|
2023-08-12 09:25:17 +00:00
|
|
|
ENV GALLERIES='[{"name":"model-gallery", "url":"github:go-skynet/model-gallery/index.yaml"}, {"url": "github:go-skynet/model-gallery/huggingface.yaml","name":"huggingface"}]'
|
2023-06-22 15:53:10 +00:00
|
|
|
ARG GO_TAGS="stablediffusion tts"
|
2023-05-29 21:12:27 +00:00
|
|
|
|
|
|
|
RUN apt-get update && \
|
2023-07-20 20:10:42 +00:00
|
|
|
apt-get install -y ca-certificates cmake curl patch pip
|
|
|
|
|
2023-08-07 21:34:01 +00:00
|
|
|
# Use the variables in subsequent instructions
|
|
|
|
RUN echo "Target Architecture: $TARGETARCH"
|
|
|
|
RUN echo "Target Variant: $TARGETVARIANT"
|
2023-05-29 21:12:27 +00:00
|
|
|
|
|
|
|
# CuBLAS requirements
|
|
|
|
RUN if [ "${BUILD_TYPE}" = "cublas" ]; then \
|
|
|
|
apt-get install -y software-properties-common && \
|
|
|
|
apt-add-repository contrib && \
|
|
|
|
curl -O https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb && \
|
|
|
|
dpkg -i cuda-keyring_1.0-1_all.deb && \
|
|
|
|
rm -f cuda-keyring_1.0-1_all.deb && \
|
|
|
|
apt-get update && \
|
2023-08-10 22:49:40 +00:00
|
|
|
apt-get install -y cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcusparse-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcusolver-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
|
2023-05-29 21:12:27 +00:00
|
|
|
; fi
|
|
|
|
ENV PATH /usr/local/cuda/bin:${PATH}
|
|
|
|
|
2023-08-07 21:34:01 +00:00
|
|
|
# Extras requirements
|
|
|
|
COPY extra/requirements.txt /build/extra/requirements.txt
|
2023-08-09 06:38:51 +00:00
|
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
2023-08-08 21:20:03 +00:00
|
|
|
RUN pip install --upgrade pip
|
2023-08-09 06:38:51 +00:00
|
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
2023-08-07 21:34:01 +00:00
|
|
|
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
|
2023-08-09 06:38:51 +00:00
|
|
|
pip install git+https://github.com/suno-ai/bark.git diffusers invisible_watermark transformers accelerate safetensors;\
|
|
|
|
fi
|
|
|
|
RUN if [ "${BUILD_TYPE}" = "cublas" ] && [ "${TARGETARCH}" = "amd64" ]; then \
|
2023-09-09 14:46:13 +00:00
|
|
|
pip install torch vllm && pip install auto-gptq https://github.com/jllllll/exllama/releases/download/0.0.10/exllama-0.0.10+cu${CUDA_MAJOR_VERSION}${CUDA_MINOR_VERSION}-cp39-cp39-linux_x86_64.whl;\
|
2023-08-07 21:34:01 +00:00
|
|
|
fi
|
|
|
|
RUN pip install -r /build/extra/requirements.txt && rm -rf /build/extra/requirements.txt
|
|
|
|
|
2023-09-04 17:25:23 +00:00
|
|
|
# Vall-e-X
|
|
|
|
RUN git clone https://github.com/Plachtaa/VALL-E-X.git /usr/lib/vall-e-x && cd /usr/lib/vall-e-x && pip install -r requirements.txt
|
|
|
|
|
2023-06-22 15:53:10 +00:00
|
|
|
WORKDIR /build
|
|
|
|
|
2023-05-29 21:12:27 +00:00
|
|
|
# OpenBLAS requirements
|
|
|
|
RUN apt-get install -y libopenblas-dev
|
|
|
|
|
|
|
|
# Stable Diffusion requirements
|
|
|
|
RUN apt-get install -y libopencv-dev && \
|
|
|
|
ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
|
|
|
|
|
2023-06-27 14:31:02 +00:00
|
|
|
|
2023-06-22 15:53:10 +00:00
|
|
|
# piper requirements
|
|
|
|
# Use pre-compiled Piper phonemization library (includes onnxruntime)
|
|
|
|
#RUN if echo "${GO_TAGS}" | grep -q "tts"; then \
|
2023-06-27 07:00:43 +00:00
|
|
|
RUN test -n "$TARGETARCH" \
|
2023-06-27 14:31:02 +00:00
|
|
|
|| (echo 'warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`')
|
|
|
|
|
2023-06-22 15:53:10 +00:00
|
|
|
RUN curl -L "https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz" | \
|
|
|
|
tar -xzvf - && \
|
|
|
|
mkdir -p "spdlog-${SPDLOG_VERSION}/build" && \
|
|
|
|
cd "spdlog-${SPDLOG_VERSION}/build" && \
|
|
|
|
cmake .. && \
|
|
|
|
make -j8 && \
|
|
|
|
cmake --install . --prefix /usr && mkdir -p "lib/Linux-$(uname -m)" && \
|
|
|
|
cd /build && \
|
|
|
|
mkdir -p "lib/Linux-$(uname -m)/piper_phonemize" && \
|
2023-06-27 14:31:02 +00:00
|
|
|
curl -L "https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-${TARGETARCH:-$(go env GOARCH)}${TARGETVARIANT}.tar.gz" | \
|
2023-06-22 15:53:10 +00:00
|
|
|
tar -C "lib/Linux-$(uname -m)/piper_phonemize" -xzvf - && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ && \
|
|
|
|
cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ && \
|
2023-07-28 17:40:21 +00:00
|
|
|
ln -s /usr/lib/libpiper_phonemize.so /usr/lib/libpiper_phonemize.so.1 && \
|
2023-06-26 20:34:03 +00:00
|
|
|
cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/
|
2023-06-22 15:53:10 +00:00
|
|
|
# \
|
|
|
|
# ; fi
|
|
|
|
|
2023-06-26 20:34:03 +00:00
|
|
|
###################################
|
|
|
|
###################################
|
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
FROM requirements as builder
|
2023-05-30 13:53:37 +00:00
|
|
|
|
2023-06-22 15:53:10 +00:00
|
|
|
ARG GO_TAGS="stablediffusion tts"
|
2023-05-30 13:53:37 +00:00
|
|
|
|
|
|
|
ENV GO_TAGS=${GO_TAGS}
|
|
|
|
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
|
|
|
ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0"
|
|
|
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
|
|
|
|
2023-06-26 20:34:03 +00:00
|
|
|
WORKDIR /build
|
|
|
|
|
|
|
|
COPY Makefile .
|
|
|
|
RUN make get-sources
|
|
|
|
COPY go.mod .
|
|
|
|
RUN make prepare
|
2023-06-13 06:39:38 +00:00
|
|
|
COPY . .
|
2023-07-02 09:14:09 +00:00
|
|
|
COPY .git .
|
|
|
|
|
2023-06-22 15:53:10 +00:00
|
|
|
RUN ESPEAK_DATA=/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data make build
|
2023-05-30 13:53:37 +00:00
|
|
|
|
2023-06-26 20:34:03 +00:00
|
|
|
###################################
|
|
|
|
###################################
|
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
FROM requirements
|
|
|
|
|
|
|
|
ARG FFMPEG
|
2023-08-12 06:56:01 +00:00
|
|
|
ARG BUILD_TYPE
|
|
|
|
ARG TARGETARCH
|
2023-06-13 06:39:38 +00:00
|
|
|
|
2023-08-12 06:56:01 +00:00
|
|
|
ENV BUILD_TYPE=${BUILD_TYPE}
|
2023-07-06 22:29:10 +00:00
|
|
|
ENV REBUILD=false
|
2023-06-13 06:39:38 +00:00
|
|
|
ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
|
2023-06-04 12:00:21 +00:00
|
|
|
|
|
|
|
# Add FFmpeg
|
|
|
|
RUN if [ "${FFMPEG}" = "true" ]; then \
|
|
|
|
apt-get install -y ffmpeg \
|
|
|
|
; fi
|
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
WORKDIR /build
|
2023-05-30 13:53:37 +00:00
|
|
|
|
2023-06-26 20:34:03 +00:00
|
|
|
# we start fresh & re-copy all assets because `make build` does not clean up nicely after itself
|
|
|
|
# so when `entrypoint.sh` runs `make build` again (which it does by default), the build would fail
|
|
|
|
# see https://github.com/go-skynet/LocalAI/pull/658#discussion_r1241971626 and
|
|
|
|
# https://github.com/go-skynet/LocalAI/pull/434
|
2023-06-17 21:22:04 +00:00
|
|
|
COPY . .
|
|
|
|
RUN make prepare-sources
|
2023-05-30 13:53:37 +00:00
|
|
|
COPY --from=builder /build/local-ai ./
|
2023-09-04 17:25:23 +00:00
|
|
|
|
|
|
|
# Copy VALLE-X as it's not a real "lib"
|
|
|
|
RUN cp -rfv /usr/lib/vall-e-x/* extra/grpc/vall-e-x/
|
|
|
|
|
2023-08-12 06:56:01 +00:00
|
|
|
# To resolve exllama import error
|
|
|
|
RUN if [ "${BUILD_TYPE}" = "cublas" ] && [ "${TARGETARCH:-$(go env GOARCH)}" = "amd64" ]; then \
|
|
|
|
cp -rfv /usr/local/lib/python3.9/dist-packages/exllama extra/grpc/exllama/;\
|
|
|
|
fi
|
2023-05-26 16:34:02 +00:00
|
|
|
# Define the health check command
|
2023-05-30 10:00:30 +00:00
|
|
|
HEALTHCHECK --interval=1m --timeout=10m --retries=10 \
|
2023-05-26 16:34:02 +00:00
|
|
|
CMD curl -f $HEALTHCHECK_ENDPOINT || exit 1
|
2023-05-29 21:12:27 +00:00
|
|
|
|
2023-04-27 16:45:24 +00:00
|
|
|
EXPOSE 8080
|
2023-06-26 20:34:03 +00:00
|
|
|
ENTRYPOINT [ "/build/entrypoint.sh" ]
|