Update Dockerfile
Browse files- Dockerfile +20 -24
Dockerfile
CHANGED
|
@@ -1,56 +1,52 @@
|
|
| 1 |
-
# Use NVIDIA
|
| 2 |
-
FROM nvidia/cuda:12.
|
| 3 |
|
| 4 |
# Prevent interactive prompts
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
|
| 7 |
-
# Install Python 3.12 and system
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
-
software-properties-common \
|
| 10 |
-
&& add-apt-repository ppa:deadsnakes/ppa \
|
| 11 |
-
&& apt-get update && apt-get install -y \
|
| 12 |
python3.12 \
|
| 13 |
python3.12-venv \
|
| 14 |
python3.12-dev \
|
|
|
|
| 15 |
git \
|
| 16 |
wget \
|
| 17 |
libgl1 \
|
| 18 |
libglib2.0-0 \
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
-
#
|
|
|
|
| 22 |
RUN useradd -m -u 1000 user
|
| 23 |
USER user
|
| 24 |
-
ENV HOME=/home/user \
|
| 25 |
-
PATH=/home/user/venv/bin:$PATH \
|
| 26 |
-
PYTHONWARNINGS="ignore::SyntaxWarning"
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
ENV
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
WORKDIR $HOME/app
|
| 36 |
|
| 37 |
-
#
|
| 38 |
RUN python3.12 -m venv $HOME/venv
|
| 39 |
|
| 40 |
-
# Install PyTorch
|
| 41 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 42 |
-
pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/
|
| 43 |
|
| 44 |
-
#
|
| 45 |
COPY --chown=user requirements.txt .
|
| 46 |
-
|
| 47 |
-
# We use --no-build-isolation to ensure extensions use the PyTorch/CUDA we just installed
|
| 48 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 49 |
|
| 50 |
-
# Copy application files
|
| 51 |
COPY --chown=user . .
|
| 52 |
|
| 53 |
-
# App settings
|
| 54 |
EXPOSE 7860
|
| 55 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 56 |
ENV GRADIO_SERVER_PORT="7860"
|
|
|
|
| 1 |
+
# 1. Use the NVIDIA image for Ubuntu 24.04 (Noble)
|
| 2 |
+
FROM nvidia/cuda:12.4.1-devel-ubuntu24.04
|
| 3 |
|
| 4 |
# Prevent interactive prompts
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
|
| 7 |
+
# 2. Install Python 3.12 and required system libraries
|
| 8 |
RUN apt-get update && apt-get install -y \
|
|
|
|
|
|
|
|
|
|
| 9 |
python3.12 \
|
| 10 |
python3.12-venv \
|
| 11 |
python3.12-dev \
|
| 12 |
+
python3-pip \
|
| 13 |
git \
|
| 14 |
wget \
|
| 15 |
libgl1 \
|
| 16 |
libglib2.0-0 \
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
+
# 3. Fix the Ubuntu 24.04 user conflict (UID 1000)
|
| 20 |
+
RUN userdel -r ubuntu || true
|
| 21 |
RUN useradd -m -u 1000 user
|
| 22 |
USER user
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
# 4. Set environment for L40S (Compute 8.9) and C++ libraries
|
| 25 |
+
ENV HOME=/home/user \
|
| 26 |
+
PATH=/home/user/venv/bin:/usr/local/cuda/bin:$PATH \
|
| 27 |
+
LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH \
|
| 28 |
+
PYTHONWARNINGS="ignore::SyntaxWarning" \
|
| 29 |
+
TORCH_CUDA_ARCH_LIST="8.9" \
|
| 30 |
+
CUDA_HOME=/usr/local/cuda
|
| 31 |
|
| 32 |
WORKDIR $HOME/app
|
| 33 |
|
| 34 |
+
# 5. Set up Virtual Environment
|
| 35 |
RUN python3.12 -m venv $HOME/venv
|
| 36 |
|
| 37 |
+
# 6. Install PyTorch with CUDA 12.4 support
|
| 38 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 39 |
+
pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
|
| 40 |
|
| 41 |
+
# 7. Install Pixal3D requirements
|
| 42 |
COPY --chown=user requirements.txt .
|
| 43 |
+
# We use --no-build-isolation to ensure it uses the CUDA 12.4 we just set up
|
|
|
|
| 44 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 45 |
|
| 46 |
+
# 8. Copy application files
|
| 47 |
COPY --chown=user . .
|
| 48 |
|
| 49 |
+
# 9. App settings
|
| 50 |
EXPOSE 7860
|
| 51 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 52 |
ENV GRADIO_SERVER_PORT="7860"
|