fffiloni commited on
Commit
ab133c6
·
verified ·
1 Parent(s): 80cd4bc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -42
Dockerfile CHANGED
@@ -1,73 +1,75 @@
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
  RUN useradd -m -u 1000 user
8
 
9
- USER user
10
-
11
- ENV HOME=/home/user \
12
- PATH=/home/user/.local/bin:$PATH \
13
- PYTHONPATH=$HOME/app \
14
- PYTHONUNBUFFERED=1 \
15
- GRADIO_ALLOW_FLAGGING=never \
16
- GRADIO_NUM_PORTS=1 \
17
- GRADIO_SERVER_NAME=0.0.0.0 \
18
- GRADIO_THEME=huggingface \
19
- GRADIO_SHARE=False \
20
- SYSTEM=spaces
21
-
22
- # Set the working directory to the user's home directory
23
- WORKDIR $HOME/app
24
-
25
  # Install system dependencies as root
26
- USER root
27
  RUN apt-get update && apt-get install -y --no-install-recommends \
28
  git \
29
  cmake \
 
30
  build-essential \
31
  libgl1-mesa-glx \
32
  libglib2.0-0 \
33
  ffmpeg \
34
- python3.8 \
35
  python3-pip \
36
- python3.8-dev \
 
37
  && rm -rf /var/lib/apt/lists/*
38
 
39
-
40
- # Set Python 3.8 as the default python and pip versions
41
- RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
42
  RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
43
 
 
44
  USER user
45
- # Clone the repository (adjust the URL if needed)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  RUN git clone --recursive https://github.com/jnjaby/KEEP.git .
47
 
48
- # Copy the app.py script into the container
49
  COPY app.py .
50
  COPY requirements_HF.txt .
51
 
52
- # Install Python dependencies from requirements.txt
53
- RUN pip install --upgrade pip
54
- RUN pip install -r requirements_HF.txt
55
- RUN pip install gradio
56
- RUN pip install https://files.pythonhosted.org/packages/40/80/f4b6a9c656daf97f1c4acfd4ae1449f4c7c4e34f1092c8ba10f29b4bc7a8/cupy_cuda11x-11.0.0-cp38-cp38-manylinux1_x86_64.whl
57
-
58
- USER root
59
- # Install basicsr (assuming setup.py is in basicsr directory)
60
- RUN python basicsr/setup.py develop
61
 
62
- USER user
63
- # Install additional Python packages
64
- RUN pip install ffmpeg-python
65
- RUN pip install dlib-bin
66
-
67
- # Set the environment variable to specify the GPU device
68
  ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
69
  ENV CUDA_VISIBLE_DEVICES=0
70
 
71
-
72
- # Command to run your application
73
  CMD ["python", "app.py"]
 
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 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 \
14
+ ninja-build \
15
  build-essential \
16
  libgl1-mesa-glx \
17
  libglib2.0-0 \
18
  ffmpeg \
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 the default python and pip versions
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
+ # Create virtual environment
33
+ RUN python -m venv /home/user/venv
34
+ ENV VIRTUAL_ENV=/home/user/venv
35
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
36
+
37
+ # Set environment variables
38
+ ENV HOME=/home/user \
39
+ CUDA_HOME=/usr/local/cuda \
40
+ LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_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
+ # Upgrade pip and install numpy<2 first, then PyTorch (with correct CUDA version)
53
+ RUN pip install --no-cache-dir --upgrade pip && \
54
+ pip install --no-cache-dir "numpy<2" && \
55
+ pip install --no-cache-dir torch==1.10.0 torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 && \
56
+ python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA Available:', torch.cuda.is_available()); print('Device:', torch.cuda.get_device_name(0))"
57
+
58
+ # Clone the repository
59
  RUN git clone --recursive https://github.com/jnjaby/KEEP.git .
60
 
61
+ # Copy application files
62
  COPY app.py .
63
  COPY requirements_HF.txt .
64
 
65
+ # Install Python dependencies
66
+ RUN pip install --no-cache-dir -r requirements_HF.txt
67
+ RUN pip install --no-cache-dir gradio ffmpeg-python dlib-
68
+ RUN pip install basicsr
 
 
 
 
 
69
 
70
+ # Set CUDA device settings
 
 
 
 
 
71
  ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
72
  ENV CUDA_VISIBLE_DEVICES=0
73
 
74
+ # Command to run the application
 
75
  CMD ["python", "app.py"]