Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +16 -39
Dockerfile
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
-
# Use the NVIDIA CUDA runtime as a base image (MATCHING PyTorch)
|
2 |
FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04
|
3 |
|
4 |
-
# Set environment variables
|
5 |
ENV DEBIAN_FRONTEND=noninteractive
|
6 |
|
7 |
-
# Create
|
8 |
RUN useradd -m -u 1000 user
|
9 |
|
10 |
-
# Install system dependencies
|
11 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
12 |
git \
|
13 |
cmake \
|
@@ -19,33 +17,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
19 |
python3.9 \
|
20 |
python3-pip \
|
21 |
python3.9-dev \
|
22 |
-
python3.9-venv \
|
23 |
&& rm -rf /var/lib/apt/lists/*
|
24 |
|
25 |
-
# Set Python 3.9 as
|
26 |
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
|
27 |
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
28 |
|
29 |
# Switch to non-root user
|
30 |
USER user
|
31 |
|
32 |
-
#
|
33 |
-
RUN python -m venv /home/user/venv
|
34 |
-
ENV VIRTUAL_ENV=/home/user/venv
|
35 |
-
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
36 |
-
|
37 |
-
# Explicitly set CUDA and PyTorch environment variables
|
38 |
-
ENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6"
|
39 |
-
ENV FORCE_CUDA=1
|
40 |
-
|
41 |
-
# Correct CUDA paths to ensure visibility
|
42 |
ENV CUDA_HOME=/usr/local/cuda
|
43 |
ENV PATH=${CUDA_HOME}/bin:${PATH}
|
44 |
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
# Set home to the user's home directory
|
47 |
ENV HOME=/home/user \
|
48 |
-
PYTHONPATH
|
49 |
PYTHONUNBUFFERED=1 \
|
50 |
GRADIO_ALLOW_FLAGGING=never \
|
51 |
GRADIO_NUM_PORTS=1 \
|
@@ -53,34 +44,20 @@ ENV HOME=/home/user \
|
|
53 |
GRADIO_THEME=huggingface \
|
54 |
SYSTEM=spaces
|
55 |
|
56 |
-
# Set working directory
|
57 |
WORKDIR $HOME/app
|
58 |
|
59 |
-
# Upgrade pip and install numpy
|
60 |
RUN pip install --no-cache-dir --upgrade pip && \
|
61 |
-
pip install --no-cache-dir "numpy<2"
|
62 |
-
|
63 |
-
|
64 |
-
RUN pip install --no-cache-dir torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 && \
|
65 |
-
python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA Available:', torch.cuda.is_available()); print('Device:', torch.cuda.get_device_name(0))"
|
66 |
|
67 |
-
# Clone
|
68 |
RUN git clone --recursive https://github.com/jnjaby/KEEP.git .
|
69 |
-
|
70 |
-
# Copy application files
|
71 |
COPY app.py .
|
72 |
COPY requirements_HF.txt .
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
RUN pip install --no-cache-dir gradio ffmpeg-python dlib-bin basicsr
|
77 |
-
|
78 |
-
# Set CUDA device settings
|
79 |
-
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
|
80 |
-
ENV CUDA_VISIBLE_DEVICES=0
|
81 |
-
|
82 |
-
# Verify CUDA after all installs (Debugging Step)
|
83 |
-
RUN python -c "import torch; print('Final Check - CUDA Available:', torch.cuda.is_available())"
|
84 |
|
85 |
-
# Command to run the application
|
86 |
CMD ["python", "app.py"]
|
|
|
|
|
1 |
FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04
|
2 |
|
|
|
3 |
ENV DEBIAN_FRONTEND=noninteractive
|
4 |
|
5 |
+
# Create non-root user
|
6 |
RUN useradd -m -u 1000 user
|
7 |
|
8 |
+
# Install system dependencies
|
9 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
10 |
git \
|
11 |
cmake \
|
|
|
17 |
python3.9 \
|
18 |
python3-pip \
|
19 |
python3.9-dev \
|
|
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
|
22 |
+
# Set Python 3.9 as default
|
23 |
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
|
24 |
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
25 |
|
26 |
# Switch to non-root user
|
27 |
USER user
|
28 |
|
29 |
+
# Set CUDA and environment variables
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
ENV CUDA_HOME=/usr/local/cuda
|
31 |
ENV PATH=${CUDA_HOME}/bin:${PATH}
|
32 |
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
33 |
+
ENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6"
|
34 |
+
ENV FORCE_CUDA=1
|
35 |
+
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
|
36 |
+
ENV CUDA_VISIBLE_DEVICES=0
|
37 |
|
|
|
38 |
ENV HOME=/home/user \
|
39 |
+
PYTHONPATH=/home/user/app \
|
40 |
PYTHONUNBUFFERED=1 \
|
41 |
GRADIO_ALLOW_FLAGGING=never \
|
42 |
GRADIO_NUM_PORTS=1 \
|
|
|
44 |
GRADIO_THEME=huggingface \
|
45 |
SYSTEM=spaces
|
46 |
|
|
|
47 |
WORKDIR $HOME/app
|
48 |
|
49 |
+
# Upgrade pip and install numpy, then PyTorch
|
50 |
RUN pip install --no-cache-dir --upgrade pip && \
|
51 |
+
pip install --no-cache-dir "numpy<2" && \
|
52 |
+
pip install --no-cache-dir torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 && \
|
53 |
+
python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA Available:', torch.cuda.is_available())"
|
|
|
|
|
54 |
|
55 |
+
# Clone repository and install dependencies
|
56 |
RUN git clone --recursive https://github.com/jnjaby/KEEP.git .
|
|
|
|
|
57 |
COPY app.py .
|
58 |
COPY requirements_HF.txt .
|
59 |
|
60 |
+
RUN pip install --no-cache-dir -r requirements_HF.txt && \
|
61 |
+
pip install --no-cache-dir gradio ffmpeg-python dlib-bin basicsr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
|
|
63 |
CMD ["python", "app.py"]
|