Created
October 15, 2023 14:18
-
-
Save JohanAR/abcb3e1830d54ba2e9bad552947adf06 to your computer and use it in GitHub Desktop.
text-generation-webui in docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 | |
# https://developer.nvidia.com/cuda-gpus | |
# for a rtx 2060: ARG TORCH_CUDA_ARCH_LIST="7.5" | |
ARG TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX}" | |
LABEL maintainer="Your Name <your.email@example.com>" | |
LABEL description="Docker image for GPTQ-for-LLaMa and Text Generation WebUI" | |
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 && \ | |
rm -rf /var/lib/apt/lists/* | |
RUN --mount=type=cache,target=/root/.cache/pip,rw \ | |
python3 -m pip install virtualenv | |
RUN mkdir /app | |
WORKDIR /app | |
ARG WEBUI_VERSION | |
RUN test -n "${WEBUI_VERSION}" && git reset --hard ${WEBUI_VERSION} || echo "Using provided webui source" | |
# Create virtualenv | |
RUN virtualenv /app/venv | |
RUN --mount=type=cache,target=/root/.cache/pip,rw \ | |
. /app/venv/bin/activate && \ | |
python3 -m pip install --upgrade pip setuptools wheel && \ | |
python3 -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 && \ | |
python3 -m pip freeze | grep == | sed 's/==/>=/' > /app/constraints.txt && \ | |
python3 -m pip install -c /app/constraints.txt "xformers>=0.0.22+cu118" | |
# Install main requirements | |
COPY requirements.txt /app/requirements.txt | |
RUN --mount=type=cache,target=/root/.cache/pip,rw \ | |
. /app/venv/bin/activate && \ | |
python3 -m pip install -c /app/constraints.txt -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 | |
# 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")"; \ | |
python3 -m pip install -c /app/constraints.txt -r requirements.txt; \ | |
done | |
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} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment