From c9aaa39890805a1bad8711622211a5d54fe761aa Mon Sep 17 00:00:00 2001 From: Ashley Kleynhans Date: Thu, 9 May 2024 11:09:25 +0200 Subject: [PATCH] Refactor installation into bash script and use uv instead of pip --- Dockerfile | 36 ++++++------------------------------ build/install.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 30 deletions(-) create mode 100644 build/install.sh diff --git a/Dockerfile b/Dockerfile index be9e1ac..9ff18dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,40 +8,16 @@ ENV DEBIAN_FRONTEND=noninteractive \ SHELL=/bin/bash \ PATH="/usr/local/cuda/bin:${PATH}" -# Install Torch +# Install oobabooga ARG INDEX_URL ARG TORCH_VERSION -WORKDIR / -RUN python3 -m venv --system-site-packages /venv && \ - source /venv/bin/activate && \ - pip3 install torch==${TORCH_VERSION} --index-url ${INDEX_URL} && \ - deactivate - -# Clone the git repo of Text Generation Web UI and set version ARG OOBABOOGA_COMMIT -RUN git clone https://github.com/oobabooga/text-generation-webui && \ - cd /text-generation-webui && \ - git checkout ${OOBABOOGA_COMMIT} - -# Install the dependencies for Text Generation Web UI -# Including all extensions -WORKDIR /text-generation-webui +ENV INDEX_URL=${INDEX_URL} +ENV TORCH_VERSION=${TORCH_VERSION} +ENV OOBABOOGA_COMMIT=${OOBABOOGA_COMMIT} #COPY oobabooga/requirements* ./ -RUN source /venv/bin/activate && \ - pip3 install -r requirements.txt && \ - bash -c 'for req in extensions/*/requirements.txt ; do pip3 install -r "$req" ; done' && \ -# mkdir -p repositories && \ -# cd repositories && \ -# git clone https://github.com/turboderp/exllamav2 && \ -# cd exllamav2 && \ -# pip3 install -r requirements.txt && \ -# pip3 install . && \ - deactivate - -# Fix safetensors module broken by above exllama repository installation -RUN source /venv/bin/activate && \ - pip3 install -U safetensors>=0.4.1 && \ - deactivate +COPY --chmod=755 build/install.sh /install.sh +RUN /install.sh && rm /install.sh # NGINX Proxy COPY nginx/nginx.conf /etc/nginx/nginx.conf diff --git a/build/install.sh b/build/install.sh new file mode 100644 index 0000000..b537713 --- /dev/null +++ b/build/install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Install uv +RUN curl -LsSf https://astral.sh/uv/install.sh | sh + +# Install torch +source ~/.bashrc +uv venv -p 3.10 /venv +source /venv/bin/activate +uv pip install torch==${TORCH_VERSION} --index-url ${INDEX_URL} + +# Clone the git repo of Text Generation Web UI and set version +git clone https://github.com/oobabooga/text-generation-webui +cd /text-generation-webui +git checkout ${OOBABOOGA_COMMIT} + +# Install the dependencies for Text Generation Web UI +# Including all extensions +uv pip install -r requirements.txt +bash -c 'for req in extensions/*/requirements.txt ; do pip3 install -r "$req" ; done' +# mkdir -p repositories +# cd repositories +# git clone https://github.com/turboderp/exllamav2 +# cd exllamav2 +# pip3 install -r requirements.txt +# pip3 install . + +# Fix safetensors module broken by above exllama repository installation +uv pip install -U safetensors>=0.4.1