2023-10-21 02:46:23 -04:00
FROM nvidia/cuda:12.1.0-devel-ubuntu22.04 as builder
2023-04-06 21:46:04 -04:00
2023-09-11 11:22:00 -04:00
RUN --mount= type = cache,target= /var/cache/apt,sharing= locked,rw apt-get update && \
2023-04-06 21:46:04 -04:00
apt-get install --no-install-recommends -y git vim build-essential python3-dev python3-venv && \
rm -rf /var/lib/apt/lists/*
2023-09-11 11:22:00 -04:00
RUN git clone --depth= 1 https://github.com/oobabooga/GPTQ-for-LLaMa /build
2023-04-06 21:46:04 -04:00
WORKDIR /build
2023-09-11 11:22:00 -04:00
RUN --mount= type = cache,target= /root/.cache/pip,rw \
python3 -m venv /build/venv && \
. /build/venv/bin/activate && \
2023-10-15 18:27:19 -04:00
pip3 install --upgrade pip setuptools wheel ninja && \
2023-10-21 14:09:34 -04:00
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 && \
2023-04-06 21:46:04 -04:00
pip3 install -r requirements.txt
# https://developer.nvidia.com/cuda-gpus
# for a rtx 2060: ARG TORCH_CUDA_ARCH_LIST="7.5"
2023-08-07 09:19:16 -04:00
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 } "
2023-04-06 21:46:04 -04:00
RUN . /build/venv/bin/activate && \
python3 setup_cuda.py bdist_wheel -d .
2023-10-21 02:46:23 -04:00
FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04
2023-04-06 21:46:04 -04:00
LABEL maintainer = "Your Name <your.email@example.com>"
LABEL description = "Docker image for GPTQ-for-LLaMa and Text Generation WebUI"
2023-09-11 11:22:00 -04:00
RUN --mount= type = cache,target= /var/cache/apt,sharing= locked,rw apt-get update && \
2023-08-27 11:29:00 -04:00
apt-get install --no-install-recommends -y python3-dev libportaudio2 libasound-dev git python3 python3-pip make g++ ffmpeg && \
2023-04-06 21:46:04 -04:00
rm -rf /var/lib/apt/lists/*
2023-09-11 11:22:00 -04:00
RUN --mount= type = cache,target= /root/.cache/pip,rw pip3 install virtualenv
2023-10-15 18:27:19 -04:00
2023-04-06 23:56:44 -04:00
RUN mkdir /app
2023-04-06 21:46:04 -04:00
WORKDIR /app
ARG WEBUI_VERSION
RUN test -n " ${ WEBUI_VERSION } " && git reset --hard ${ WEBUI_VERSION } || echo "Using provided webui source"
2023-09-11 11:22:00 -04:00
# Create virtualenv
2023-04-06 21:46:04 -04:00
RUN virtualenv /app/venv
2023-09-11 11:22:00 -04:00
RUN --mount= type = cache,target= /root/.cache/pip,rw \
. /app/venv/bin/activate && \
2023-10-15 18:27:19 -04:00
pip3 install --upgrade pip setuptools wheel ninja && \
2023-10-21 14:09:34 -04:00
pip3 install torch --index-url https://download.pytorch.org/whl/cu121 && \
2023-10-15 18:27:19 -04:00
pip3 install torchvision torchaudio sentence_transformers xformers
2023-04-06 21:46:04 -04:00
2023-09-11 11:22:00 -04:00
# Copy and install GPTQ-for-LLaMa
2023-04-06 21:46:04 -04:00
COPY --from= builder /build /app/repositories/GPTQ-for-LLaMa
2023-09-11 11:22:00 -04:00
RUN --mount= type = cache,target= /root/.cache/pip,rw \
. /app/venv/bin/activate && \
2023-04-06 21:46:04 -04:00
pip3 install /app/repositories/GPTQ-for-LLaMa/*.whl
2023-09-11 11:22:00 -04:00
# Install main requirements
2023-04-06 23:56:44 -04:00
COPY requirements.txt /app/requirements.txt
2023-09-11 11:22:00 -04:00
RUN --mount= type = cache,target= /root/.cache/pip,rw \
. /app/venv/bin/activate && \
2023-04-06 23:56:44 -04:00
pip3 install -r requirements.txt
2023-09-11 11:22:00 -04:00
COPY . /app/
2023-10-21 14:09:34 -04:00
RUN cp /app/venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda121.so /app/venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so
2023-04-06 21:46:04 -04:00
2023-09-11 11:22:00 -04:00
# 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
2023-04-06 23:56:44 -04:00
ENV CLI_ARGS = ""
2023-09-11 11:22:00 -04:00
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
2023-04-06 21:46:04 -04:00
CMD . /app/venv/bin/activate && python3 server.py ${ CLI_ARGS }