Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +50 -47
Dockerfile
CHANGED
|
@@ -1,52 +1,34 @@
|
|
| 1 |
FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
|
| 2 |
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
-
TZ=Asia/Kolkata
|
|
|
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
RUN rm -f /etc/apt/sources.list.d/*.list && \
|
| 8 |
apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
-
curl \
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
git \
|
| 13 |
-
wget \
|
| 14 |
-
procps \
|
| 15 |
-
git-lfs \
|
| 16 |
-
zip \
|
| 17 |
-
unzip \
|
| 18 |
-
htop \
|
| 19 |
-
vim \
|
| 20 |
-
nano \
|
| 21 |
-
bzip2 \
|
| 22 |
-
libx11-6 \
|
| 23 |
-
build-essential \
|
| 24 |
-
libsndfile-dev \
|
| 25 |
-
software-properties-common \
|
| 26 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 27 |
-
|
| 28 |
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
|
| 29 |
apt-get upgrade -y && \
|
| 30 |
apt-get install -y --no-install-recommends nvtop
|
| 31 |
|
| 32 |
-
RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
|
| 33 |
-
apt-get install -y nodejs && \
|
| 34 |
-
npm install -g configurable-http-proxy
|
| 35 |
-
|
| 36 |
# Create a working directory
|
| 37 |
WORKDIR /app
|
| 38 |
|
| 39 |
-
# Create non-root user
|
| 40 |
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
|
| 41 |
&& chown -R user:user /app
|
| 42 |
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 43 |
USER user
|
| 44 |
|
|
|
|
| 45 |
ENV HOME=/home/user
|
| 46 |
RUN mkdir $HOME/.cache $HOME/.config \
|
| 47 |
&& chmod -R 777 $HOME
|
| 48 |
|
| 49 |
-
#
|
| 50 |
ENV CONDA_AUTO_UPDATE_CONDA=false \
|
| 51 |
PATH=$HOME/miniconda/bin:$PATH
|
| 52 |
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
|
|
@@ -58,41 +40,62 @@ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39
|
|
| 58 |
WORKDIR $HOME/app
|
| 59 |
|
| 60 |
#######################################
|
| 61 |
-
#
|
| 62 |
#######################################
|
|
|
|
| 63 |
USER root
|
| 64 |
|
| 65 |
-
#
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
&&
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
RUN mkdir /data && chown user:user /data
|
| 71 |
|
| 72 |
#######################################
|
| 73 |
-
# End root section
|
| 74 |
#######################################
|
|
|
|
| 75 |
USER user
|
| 76 |
|
| 77 |
-
#
|
| 78 |
-
RUN
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
#
|
| 82 |
-
RUN
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
# Copy
|
| 85 |
COPY --chown=user . $HOME/app
|
| 86 |
|
| 87 |
RUN chmod +x start_server.sh
|
| 88 |
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
ENV PYTHONUNBUFFERED=1 \
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
-
|
| 95 |
-
EXPOSE 7860
|
| 96 |
|
| 97 |
-
# Start vLLM API server
|
| 98 |
-
CMD ["python3", "-m", "vllm.entrypoints.api_server", "--model", "unsloth/llama-2-7b-bnb-4bit", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
|
| 2 |
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
+
TZ=Asia/Kolkata \
|
| 5 |
+
PYTHONUNBUFFERED=1
|
| 6 |
|
| 7 |
+
# Basic deps
|
| 8 |
+
RUN RUN rm -f /etc/apt/sources.list.d/*.list && \
|
| 9 |
apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
+
python3 python3-pip python3-venv git curl wget ca-certificates && \
|
| 11 |
+
rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
|
| 14 |
apt-get upgrade -y && \
|
| 15 |
apt-get install -y --no-install-recommends nvtop
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# Create a working directory
|
| 18 |
WORKDIR /app
|
| 19 |
|
| 20 |
+
# Create a non-root user and switch to it
|
| 21 |
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
|
| 22 |
&& chown -R user:user /app
|
| 23 |
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 24 |
USER user
|
| 25 |
|
| 26 |
+
# All users can use /home/user as their home directory
|
| 27 |
ENV HOME=/home/user
|
| 28 |
RUN mkdir $HOME/.cache $HOME/.config \
|
| 29 |
&& chmod -R 777 $HOME
|
| 30 |
|
| 31 |
+
# Set up the Conda environment
|
| 32 |
ENV CONDA_AUTO_UPDATE_CONDA=false \
|
| 33 |
PATH=$HOME/miniconda/bin:$PATH
|
| 34 |
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
|
|
|
|
| 40 |
WORKDIR $HOME/app
|
| 41 |
|
| 42 |
#######################################
|
| 43 |
+
# Start root user section
|
| 44 |
#######################################
|
| 45 |
+
|
| 46 |
USER root
|
| 47 |
|
| 48 |
+
# User Debian packages
|
| 49 |
+
## Security warning : Potential user code executed as root (build time)
|
| 50 |
+
RUN --mount=target=/root/packages.txt,source=packages.txt \
|
| 51 |
+
apt-get update && \
|
| 52 |
+
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
|
| 53 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 54 |
+
|
| 55 |
+
RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
|
| 56 |
+
bash /root/on_startup.sh
|
| 57 |
|
| 58 |
RUN mkdir /data && chown user:user /data
|
| 59 |
|
| 60 |
#######################################
|
| 61 |
+
# End root user section
|
| 62 |
#######################################
|
| 63 |
+
|
| 64 |
USER user
|
| 65 |
|
| 66 |
+
# # Python packages
|
| 67 |
+
# RUN --mount=target=requirements.txt,source=requirements.txt \
|
| 68 |
+
# pip install --no-cache-dir --upgrade -r requirements.txt
|
| 69 |
+
|
| 70 |
+
# Upgrade pip
|
| 71 |
+
RUN python3 -m pip install --upgrade pip
|
| 72 |
|
| 73 |
+
# Install CUDA-compatible torch first, then vLLM
|
| 74 |
+
RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 \
|
| 75 |
+
torch torchvision torchaudio && \
|
| 76 |
+
pip install --no-cache-dir vllm
|
| 77 |
+
pip install vllm --torch-backend=auto
|
| 78 |
|
| 79 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 80 |
COPY --chown=user . $HOME/app
|
| 81 |
|
| 82 |
RUN chmod +x start_server.sh
|
| 83 |
|
| 84 |
+
|
| 85 |
+
# Default env vars
|
| 86 |
+
ENV MODEL_NAME="unsloth/llama-2-7b-bnb-4bit" \
|
| 87 |
+
VLLM_PORT=7860 \
|
| 88 |
+
HOST=0.0.0.0 \
|
| 89 |
+
TP_SIZE=1 \
|
| 90 |
+
GPU_MEMORY_UTILIZATION=0.90
|
| 91 |
+
|
| 92 |
ENV PYTHONUNBUFFERED=1 \
|
| 93 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 94 |
+
GRADIO_NUM_PORTS=1 \
|
| 95 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 96 |
+
GRADIO_THEME=huggingface \
|
| 97 |
+
SYSTEM=spaces \
|
| 98 |
+
SHELL=/bin/bash
|
| 99 |
|
| 100 |
+
CMD ["./start_server.sh"]
|
|
|
|
| 101 |
|
|
|
|
|
|