Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +19 -15
Dockerfile
CHANGED
|
@@ -1,29 +1,33 @@
|
|
| 1 |
-
# Use an official
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# Create a dedicated, non-root user for security.
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
USER user
|
| 7 |
|
| 8 |
-
# Set environment variables
|
| 9 |
ENV HOME=/home/user
|
| 10 |
ENV PATH=$HOME/.local/bin:$PATH
|
| 11 |
ENV TRANSFORMERS_CACHE=$HOME/.cache
|
| 12 |
WORKDIR $HOME/app
|
| 13 |
|
| 14 |
-
# Copy
|
| 15 |
COPY --chown=user:user ./requirements.txt .
|
| 16 |
-
|
| 17 |
-
# --- BUILD FIX v3 ---
|
| 18 |
-
# 1. Upgrade pip itself and install the key build-time dependencies first.
|
| 19 |
-
# flash-attn needs 'packaging' AND 'torch' to build itself.
|
| 20 |
-
RUN pip install --no-cache-dir --upgrade pip setuptools
|
| 21 |
-
RUN pip install --no-cache-dir packaging
|
| 22 |
-
RUN pip install --no-cache-dir torch==2.1.2
|
| 23 |
-
|
| 24 |
-
# 2. Now, install all the other requirements.
|
| 25 |
-
# pip will use the already-installed torch and not try to reinstall it.
|
| 26 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 27 |
|
| 28 |
# Copy the rest of the application
|
| 29 |
COPY --chown=user:user ./app.py .
|
|
|
|
| 1 |
+
# Use an official NVIDIA CUDA image that includes the full CUDA Toolkit (nvcc).
|
| 2 |
+
# This is required to compile flash_attn from source.
|
| 3 |
+
# We are using CUDA 12.1.1 which is compatible with torch 2.1.2+cu121.
|
| 4 |
+
FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
|
| 5 |
+
|
| 6 |
+
# Avoid prompts during package installation
|
| 7 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 8 |
+
|
| 9 |
+
# Install Python 3.9 and pip
|
| 10 |
+
RUN apt-get update && \
|
| 11 |
+
apt-get install -y python3.9 python3.9-venv python3-pip python3.9-dev && \
|
| 12 |
+
apt-get clean
|
| 13 |
+
|
| 14 |
+
# Create a symlink so 'python' and 'pip' point to the correct versions
|
| 15 |
+
RUN ln -s /usr/bin/python3.9 /usr/local/bin/python
|
| 16 |
+
RUN ln -s /usr/bin/pip3 /usr/local/bin/pip
|
| 17 |
|
| 18 |
# Create a dedicated, non-root user for security.
|
| 19 |
RUN useradd -m -u 1000 user
|
| 20 |
USER user
|
| 21 |
|
| 22 |
+
# Set environment variables for the new user
|
| 23 |
ENV HOME=/home/user
|
| 24 |
ENV PATH=$HOME/.local/bin:$PATH
|
| 25 |
ENV TRANSFORMERS_CACHE=$HOME/.cache
|
| 26 |
WORKDIR $HOME/app
|
| 27 |
|
| 28 |
+
# Copy requirements file and install dependencies
|
| 29 |
COPY --chown=user:user ./requirements.txt .
|
| 30 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Copy the rest of the application
|
| 33 |
COPY --chown=user:user ./app.py .
|