mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 01:09:22 +01:00
improve docker builds (#3715)
This commit is contained in:
parent
92f3cd624c
commit
fa363da7ce
@ -1,15 +1,16 @@
|
|||||||
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 as builder
|
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 as builder
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw apt-get update && \
|
||||||
apt-get install --no-install-recommends -y git vim build-essential python3-dev python3-venv && \
|
apt-get install --no-install-recommends -y git vim build-essential python3-dev python3-venv && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN git clone https://github.com/oobabooga/GPTQ-for-LLaMa /build
|
RUN git clone --depth=1 https://github.com/oobabooga/GPTQ-for-LLaMa /build
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
RUN python3 -m venv /build/venv
|
RUN --mount=type=cache,target=/root/.cache/pip,rw \
|
||||||
RUN . /build/venv/bin/activate && \
|
python3 -m venv /build/venv && \
|
||||||
|
. /build/venv/bin/activate && \
|
||||||
pip3 install --upgrade pip setuptools wheel && \
|
pip3 install --upgrade pip setuptools wheel && \
|
||||||
pip3 install torch torchvision torchaudio && \
|
pip3 install torch torchvision torchaudio && \
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
@ -25,11 +26,11 @@ FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
|
|||||||
LABEL maintainer="Your Name <your.email@example.com>"
|
LABEL maintainer="Your Name <your.email@example.com>"
|
||||||
LABEL description="Docker image for GPTQ-for-LLaMa and Text Generation WebUI"
|
LABEL description="Docker image for GPTQ-for-LLaMa and Text Generation WebUI"
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw apt-get update && \
|
||||||
apt-get install --no-install-recommends -y python3-dev libportaudio2 libasound-dev git python3 python3-pip make g++ ffmpeg && \
|
apt-get install --no-install-recommends -y python3-dev libportaudio2 libasound-dev git python3 python3-pip make g++ ffmpeg && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip pip3 install virtualenv
|
RUN --mount=type=cache,target=/root/.cache/pip,rw pip3 install virtualenv
|
||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@ -37,36 +38,38 @@ WORKDIR /app
|
|||||||
ARG WEBUI_VERSION
|
ARG WEBUI_VERSION
|
||||||
RUN test -n "${WEBUI_VERSION}" && git reset --hard ${WEBUI_VERSION} || echo "Using provided webui source"
|
RUN test -n "${WEBUI_VERSION}" && git reset --hard ${WEBUI_VERSION} || echo "Using provided webui source"
|
||||||
|
|
||||||
|
# Create virtualenv
|
||||||
RUN virtualenv /app/venv
|
RUN virtualenv /app/venv
|
||||||
RUN . /app/venv/bin/activate && \
|
RUN --mount=type=cache,target=/root/.cache/pip,rw \
|
||||||
|
. /app/venv/bin/activate && \
|
||||||
pip3 install --upgrade pip setuptools wheel && \
|
pip3 install --upgrade pip setuptools wheel && \
|
||||||
pip3 install torch torchvision torchaudio
|
pip3 install torch torchvision torchaudio sentence_transformers xformers
|
||||||
|
|
||||||
|
# Copy and install GPTQ-for-LLaMa
|
||||||
COPY --from=builder /build /app/repositories/GPTQ-for-LLaMa
|
COPY --from=builder /build /app/repositories/GPTQ-for-LLaMa
|
||||||
RUN . /app/venv/bin/activate && \
|
RUN --mount=type=cache,target=/root/.cache/pip,rw \
|
||||||
|
. /app/venv/bin/activate && \
|
||||||
pip3 install /app/repositories/GPTQ-for-LLaMa/*.whl
|
pip3 install /app/repositories/GPTQ-for-LLaMa/*.whl
|
||||||
|
|
||||||
COPY extensions/api/requirements.txt /app/extensions/api/requirements.txt
|
# Install main requirements
|
||||||
COPY extensions/elevenlabs_tts/requirements.txt /app/extensions/elevenlabs_tts/requirements.txt
|
|
||||||
COPY extensions/google_translate/requirements.txt /app/extensions/google_translate/requirements.txt
|
|
||||||
COPY extensions/silero_tts/requirements.txt /app/extensions/silero_tts/requirements.txt
|
|
||||||
COPY extensions/whisper_stt/requirements.txt /app/extensions/whisper_stt/requirements.txt
|
|
||||||
COPY extensions/superbooga/requirements.txt /app/extensions/superbooga/requirements.txt
|
|
||||||
COPY extensions/openai/requirements.txt /app/extensions/openai/requirements.txt
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip . /app/venv/bin/activate && cd extensions/api && pip3 install -r requirements.txt
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip . /app/venv/bin/activate && cd extensions/elevenlabs_tts && pip3 install -r requirements.txt
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip . /app/venv/bin/activate && cd extensions/google_translate && pip3 install -r requirements.txt
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip . /app/venv/bin/activate && cd extensions/silero_tts && pip3 install -r requirements.txt
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip . /app/venv/bin/activate && cd extensions/whisper_stt && pip3 install -r requirements.txt
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip . /app/venv/bin/activate && cd extensions/superbooga && pip3 install -r requirements.txt
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip . /app/venv/bin/activate && cd extensions/openai && pip3 install -r requirements.txt
|
|
||||||
|
|
||||||
COPY requirements.txt /app/requirements.txt
|
COPY requirements.txt /app/requirements.txt
|
||||||
RUN . /app/venv/bin/activate && \
|
RUN --mount=type=cache,target=/root/.cache/pip,rw \
|
||||||
|
. /app/venv/bin/activate && \
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
COPY . /app/
|
||||||
|
|
||||||
RUN cp /app/venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda118.so /app/venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so
|
RUN cp /app/venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda118.so /app/venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so
|
||||||
|
|
||||||
COPY . /app/
|
# Install extension requirements
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/pip,rw \
|
||||||
|
. /app/venv/bin/activate && \
|
||||||
|
for ext in /app/extensions/*/requirements.txt; do \
|
||||||
|
cd "$(dirname "$ext")"; \
|
||||||
|
pip3 install -r requirements.txt; \
|
||||||
|
done
|
||||||
|
|
||||||
ENV CLI_ARGS=""
|
ENV CLI_ARGS=""
|
||||||
|
|
||||||
|
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
|
||||||
CMD . /app/venv/bin/activate && python3 server.py ${CLI_ARGS}
|
CMD . /app/venv/bin/activate && python3 server.py ${CLI_ARGS}
|
||||||
|
Loading…
Reference in New Issue
Block a user