fffiloni commited on
Commit
c49c14d
·
verified ·
1 Parent(s): 3ba6280

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -46
Dockerfile CHANGED
@@ -1,34 +1,13 @@
1
  # Use the NVIDIA CUDA runtime as a base image
2
  FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04
3
- #FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
4
 
5
  # Set environment variables
6
  ENV DEBIAN_FRONTEND=noninteractive
7
 
 
8
  RUN useradd -m -u 1000 user
9
 
10
- USER user
11
-
12
- # Set environment variables including PATH for user-installed binaries
13
- ENV HOME=/home/user \
14
- CUDA_HOME=/usr/local/cuda \
15
- PATH=/home/user/.local/bin:${PATH} \
16
- LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} \
17
- LIBRARY_PATH=${CUDA_HOME}/lib64/stubs:${LIBRARY_PATH} \
18
- PYTHONPATH=/home/user/.local/lib/python3.9/site-packages:$HOME/app \
19
- PYTHONUNBUFFERED=1 \
20
- GRADIO_ALLOW_FLAGGING=never \
21
- GRADIO_NUM_PORTS=1 \
22
- GRADIO_SERVER_NAME=0.0.0.0 \
23
- GRADIO_THEME=huggingface \
24
- GRADIO_SHARE=False \
25
- SYSTEM=spaces
26
-
27
- # Set the working directory to the user's home directory
28
- WORKDIR $HOME/app
29
-
30
  # Install system dependencies as root
31
- USER root
32
  RUN apt-get update && apt-get install -y --no-install-recommends \
33
  git \
34
  cmake \
@@ -46,41 +25,57 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
46
  RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
47
  RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
48
 
49
- # Configure git to trust the directory
50
- RUN git config --global --add safe.directory /home/user/app
51
- RUN chown -R user:user /home/user/app
52
-
53
  USER user
54
- # Clone the repository (adjust the URL if needed)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  RUN git clone --recursive https://github.com/jnjaby/KEEP.git .
56
 
57
- # Copy the app.py script into the container
58
  COPY app.py .
59
  COPY requirements_HF.txt .
60
 
61
- # Install Python dependencies from requirements.txt
62
- RUN pip install --upgrade pip
63
- RUN pip install -r requirements_HF.txt
64
- RUN pip install gradio
65
-
66
 
67
- # Install torch explicitly first
68
- RUN pip install torch>=1.7.1 torchvision --extra-index-url https://download.pytorch.org/whl/cu113
69
- # Verify torch installation
70
- RUN python -c "import torch; print(torch.__version__)"
71
 
72
- # Install basicsr with the --user flag
73
- RUN python basicsr/setup.py develop --user
74
 
75
- # Install specific Cython version known to work with cupy
76
- RUN pip install cython
77
- # Install additional Python packages
78
- RUN pip install ffmpeg-python
79
- RUN pip install dlib
80
 
81
- # Set the environment variable to specify the GPU device
82
  ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
83
  ENV CUDA_VISIBLE_DEVICES=0
84
 
85
- # Command to run your application
86
  CMD ["python", "app.py"]
 
1
  # Use the NVIDIA CUDA runtime as a base image
2
  FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04
 
3
 
4
  # Set environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive
6
 
7
+ # Create a non-root user
8
  RUN useradd -m -u 1000 user
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Install system dependencies as root
 
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
  git \
13
  cmake \
 
25
  RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
26
  RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
27
 
28
+ # Switch to non-root user
 
 
 
29
  USER user
30
+
31
+ # Create virtual environment
32
+ RUN python -m venv /home/user/venv
33
+ ENV VIRTUAL_ENV=/home/user/venv
34
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
35
+
36
+ # Set environment variables
37
+ ENV HOME=/home/user \
38
+ CUDA_HOME=/usr/local/cuda \
39
+ LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} \
40
+ LIBRARY_PATH=${CUDA_HOME}/lib64/stubs:${LIBRARY_PATH} \
41
+ PYTHONUNBUFFERED=1 \
42
+ GRADIO_ALLOW_FLAGGING=never \
43
+ GRADIO_NUM_PORTS=1 \
44
+ GRADIO_SERVER_NAME=0.0.0.0 \
45
+ GRADIO_THEME=huggingface \
46
+ GRADIO_SHARE=False \
47
+ SYSTEM=spaces
48
+
49
+ # Set working directory
50
+ WORKDIR $HOME/app
51
+
52
+ # Install PyTorch first
53
+ RUN pip install --no-cache-dir torch==1.7.1 torchvision --extra-index-url https://download.pytorch.org/whl/cu113 && \
54
+ python -c "import torch; print('PyTorch version:', torch.__version__)"
55
+
56
+ # Clone the repository
57
  RUN git clone --recursive https://github.com/jnjaby/KEEP.git .
58
 
59
+ # Copy application files
60
  COPY app.py .
61
  COPY requirements_HF.txt .
62
 
63
+ # Install Python dependencies
64
+ RUN pip install --no-cache-dir -r requirements_HF.txt
65
+ RUN pip install --no-cache-dir gradio
 
 
66
 
67
+ # Install Cython (needed for some dependencies)
68
+ RUN pip install --no-cache-dir cython
 
 
69
 
70
+ # Install basicsr
71
+ RUN python basicsr/setup.py develop
72
 
73
+ # Install additional packages
74
+ RUN pip install --no-cache-dir ffmpeg-python dlib
 
 
 
75
 
76
+ # Set CUDA device settings
77
  ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
78
  ENV CUDA_VISIBLE_DEVICES=0
79
 
80
+ # Command to run the application
81
  CMD ["python", "app.py"]