From 99cf0b6d7b01f2b344c81306af2808ebcbd1c691 Mon Sep 17 00:00:00 2001 From: city_unit <140349364+city-unit@users.noreply.github.com> Date: Sun, 19 Nov 2023 00:01:17 -0500 Subject: [PATCH 1/3] Add basic docker support --- Docker | 37 +++++++++++++++++++++++++++++++++++++ docker-compose.yml | 13 +++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Docker create mode 100644 docker-compose.yml diff --git a/Docker b/Docker new file mode 100644 index 0000000..391489d --- /dev/null +++ b/Docker @@ -0,0 +1,37 @@ +# Use an official CUDA runtime with Ubuntu as a parent image +FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 + +# Install Python and pip +RUN apt-get update && apt-get install -y \ + python3.11 \ + python3-pip \ + && rm -rf /var/lib/apt/lists/* + +# Alias python and pip to python3 and pip3 +#RUN ln -s /usr/bin/python3 /usr/bin/python + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Copy the current directory contents into the container at /usr/src/app +COPY . . + +# Install torch with CUDA support and exllamav2 +RUN pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121 +RUN pip install exllamav2 + +# Install any other needed packages specified in requirements.txt +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the sample config file to the main config +RUN cp config_sample.yml config.yml + +# Make port 5000 available to the world outside this container +EXPOSE 5000 + +# Define environment variable +ENV NAME World + +# Run main.py when the container launches +CMD ["python3", "main.py"] + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..779bab6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.8' +services: + tabbyapi: + build: . + ports: + - "5000:5000" + runtime: nvidia + environment: + - NAME=TabbyAPI + - NVIDIA_VISIBLE_DEVICES=all +# volumes: +# - /path/to/models:/usr/src/app/models +# - /path/to/config:/usr/src/app/config.yml From 6b22dc0119849f8f63a4d69e1f4cac797355aa70 Mon Sep 17 00:00:00 2001 From: city_unit <140349364+city-unit@users.noreply.github.com> Date: Sun, 19 Nov 2023 00:32:14 -0500 Subject: [PATCH 2/3] Rename, fschat support --- Docker => Dockerfile | 11 ++++++++--- docker-compose.yml | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) rename Docker => Dockerfile (75%) diff --git a/Docker b/Dockerfile similarity index 75% rename from Docker rename to Dockerfile index 391489d..5cb178a 100644 --- a/Docker +++ b/Dockerfile @@ -7,8 +7,11 @@ RUN apt-get update && apt-get install -y \ python3-pip \ && rm -rf /var/lib/apt/lists/* -# Alias python and pip to python3 and pip3 -#RUN ln -s /usr/bin/python3 /usr/bin/python +# Define a build-time argument for conditional installation +ARG INSTALL_FSCHAT=false + +# Set the environment variable based on the build argument +ENV INSTALL_FSCHAT=$INSTALL_FSCHAT # Set the working directory in the container WORKDIR /usr/src/app @@ -23,6 +26,9 @@ RUN pip install exllamav2 # Install any other needed packages specified in requirements.txt RUN pip install --no-cache-dir -r requirements.txt +# Conditional installation of fschat[model_worker] +RUN if [ "$INSTALL_FSCHAT" = "true" ] ; then pip install fschat[model_worker] ; fi + # Copy the sample config file to the main config RUN cp config_sample.yml config.yml @@ -34,4 +40,3 @@ ENV NAME World # Run main.py when the container launches CMD ["python3", "main.py"] - diff --git a/docker-compose.yml b/docker-compose.yml index 779bab6..0f6e281 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,15 @@ version: '3.8' services: tabbyapi: - build: . + build: + context: . + args: + INSTALL_FSCHAT: "true" # Set this to "true" or "false" as needed ports: - "5000:5000" runtime: nvidia environment: - NAME=TabbyAPI - NVIDIA_VISIBLE_DEVICES=all -# volumes: -# - /path/to/models:/usr/src/app/models -# - /path/to/config:/usr/src/app/config.yml + volumes: + - /mnt/nvme/models:/usr/src/app/models From 80c69939ae4a8ac6485a86bfad82853584986fe4 Mon Sep 17 00:00:00 2001 From: city_unit <140349364+city-unit@users.noreply.github.com> Date: Sun, 19 Nov 2023 00:34:54 -0500 Subject: [PATCH 3/3] Remove unneeded stuffs --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5cb178a..79c53eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ WORKDIR /usr/src/app COPY . . # Install torch with CUDA support and exllamav2 -RUN pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121 +RUN pip install torch --extra-index-url https://download.pytorch.org/whl/cu121 RUN pip install exllamav2 # Install any other needed packages specified in requirements.txt