fffiloni commited on
Commit
2630fab
·
verified ·
1 Parent(s): dabec21

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -45
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV MKL_THREADING_LAYER=GNU
@@ -6,74 +6,67 @@ ENV MKL_THREADING_LAYER=GNU
6
  # Install dependencies
7
  RUN apt-get update && apt-get install -y \
8
  git wget libgl1-mesa-glx libglib2.0-0 ffmpeg libx264-dev pkg-config \
9
- build-essential cmake g++ software-properties-common \
10
- gnupg2 libopenblas-dev libx11-dev && \
11
  rm -rf /var/lib/apt/lists/*
12
 
13
  # Add NVIDIA package repositories
14
- RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
15
- dpkg -i cuda-keyring_1.1-1_all.deb && \
16
  apt-get update
17
 
18
- # Install CUDA Toolkit and cuDNN (with version matching the base image)
19
- RUN apt-get install -y cuda-toolkit-12-1 libcudnn8 libcudnn8-dev
20
 
21
- # Create user first so we can set up their home directory
22
  RUN useradd -m -u 1000 user
 
23
 
24
- # Set environment variables including HOME
25
  ENV HOME=/home/user \
26
  PATH=/home/user/.local/bin:/usr/local/cuda/bin:$PATH \
 
 
 
 
 
 
 
 
27
  CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
28
  CUDA_HOME=/usr/local/cuda \
29
  LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH \
30
- CMAKE_PREFIX_PATH="/usr/local/cuda:/usr/lib/x86_64-linux-gnu/" \
31
- TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;8.9;9.0"
32
 
33
- # Create app directory structure but don't switch to user yet
34
- RUN mkdir -p /home/user/app/checkpoints && \
35
- chown -R user:user /home/user
36
 
37
- # Clone the repository directly into the app directory (as root for now)
38
- RUN git clone -b dev https://github.com/fffiloni/dreamtalk /home/user/app && \
39
- chown -R user:user /home/user/app
40
 
41
- # Download model checkpoints (as root)
42
- RUN wget https://huggingface.co/camenduru/dreamtalk/resolve/main/damo/dreamtalk/checkpoints/denoising_network.pth -O /home/user/app/checkpoints/denoising_network.pth && \
43
- wget https://huggingface.co/camenduru/dreamtalk/resolve/main/damo/dreamtalk/checkpoints/renderer.pt -O /home/user/app/checkpoints/renderer.pt && \
44
- chown -R user:user /home/user/app/checkpoints
45
 
46
- # Switch to user for pip installations
47
- USER user
48
- WORKDIR $HOME
49
 
50
  # Upgrade pip & install dependencies
51
  RUN pip install --upgrade pip setuptools wheel
52
- RUN pip install --no-cache-dir urllib3 transformers yacs scipy scikit-image scikit-learn PyYAML Pillow "numpy<2" opencv-python imageio ffmpeg-python av "moviepy<2" gradio cmake
53
 
54
- # Explicitly set environment variables for dlib compilation
55
- ENV DLIB_USE_CUDA=1 \
56
- DLIB_JPEG_SUPPORT=1 \
57
- DLIB_PNG_SUPPORT=1 \
58
- PYTHONPATH=$HOME/app \
59
- PYTHONUNBUFFERED=1 \
60
- GRADIO_ALLOW_FLAGGING=never \
61
- GRADIO_NUM_PORTS=1 \
62
- GRADIO_SERVER_NAME=0.0.0.0 \
63
- GRADIO_THEME=huggingface \
64
- GRADIO_SHARE=False \
65
- SYSTEM=spaces \
66
- CUDA_DEVICE_ORDER=PCI_BUS_ID \
67
- CUDA_VISIBLE_DEVICES=0
68
 
69
- # Install dlib with CUDA support
70
- RUN pip install --no-cache-dir dlib==19.24.0
71
 
72
- # Set working directory to app
73
- WORKDIR $HOME/app
74
 
75
- # Copy application file (assuming it's in the build context)
76
- COPY --chown=user:user app.py $HOME/app/
 
77
 
78
  # Run the application
79
  CMD ["python", "app.py"]
 
1
+ FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV MKL_THREADING_LAYER=GNU
 
6
  # Install dependencies
7
  RUN apt-get update && apt-get install -y \
8
  git wget libgl1-mesa-glx libglib2.0-0 ffmpeg libx264-dev pkg-config \
9
+ build-essential cmake g++ python3-dev software-properties-common \
10
+ wget gnupg2 libopenblas-dev && \
11
  rm -rf /var/lib/apt/lists/*
12
 
13
  # Add NVIDIA package repositories
14
+ RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb && \
15
+ dpkg -i cuda-keyring_1.0-1_all.deb && \
16
  apt-get update
17
 
18
+ # Install CUDA Toolkit and cuDNN
19
+ RUN apt-get install -y cuda-toolkit-11-7 libcudnn8 libcudnn8-dev
20
 
21
+ # Create a user
22
  RUN useradd -m -u 1000 user
23
+ USER user
24
 
25
+ # Set CUDA paths
26
  ENV HOME=/home/user \
27
  PATH=/home/user/.local/bin:/usr/local/cuda/bin:$PATH \
28
+ PYTHONPATH=$HOME/app \
29
+ PYTHONUNBUFFERED=1 \
30
+ GRADIO_ALLOW_FLAGGING=never \
31
+ GRADIO_NUM_PORTS=1 \
32
+ GRADIO_SERVER_NAME=0.0.0.0 \
33
+ GRADIO_THEME=huggingface \
34
+ GRADIO_SHARE=False \
35
+ SYSTEM=spaces \
36
  CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
37
  CUDA_HOME=/usr/local/cuda \
38
  LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH \
39
+ TORCH_CUDA_ARCH_LIST="8.6"
 
40
 
41
+ # Set CUDA & cuDNN paths
42
+ ENV CMAKE_PREFIX_PATH="/usr/local/cuda:/usr/lib/x86_64-linux-gnu/"
 
43
 
44
+ # Set working directory
45
+ WORKDIR $HOME/app
 
46
 
47
+ # Clone the repository
48
+ RUN git clone -b dev https://github.com/fffiloni/dreamtalk $HOME/app
 
 
49
 
50
+ # Download model checkpoints
51
+ RUN wget https://huggingface.co/camenduru/dreamtalk/resolve/main/damo/dreamtalk/checkpoints/denoising_network.pth -O $HOME/app/checkpoints/denoising_network.pth
52
+ RUN wget https://huggingface.co/camenduru/dreamtalk/resolve/main/damo/dreamtalk/checkpoints/renderer.pt -O $HOME/app/checkpoints/renderer.pt
53
 
54
  # Upgrade pip & install dependencies
55
  RUN pip install --upgrade pip setuptools wheel
56
+ RUN pip install --no-cache-dir urllib3 transformers yacs scipy scikit-image scikit-learn PyYAML Pillow "numpy<2" opencv-python imageio ffmpeg-python av "moviepy<2" gradio
57
 
58
+ # Install CMake first
59
+ RUN pip install cmake
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
+ # Install dlib with CUDA support (force source compilation)
62
+ RUN pip install --no-cache-dir dlib -vvv --no-binary dlib
63
 
64
+ # Copy application file
65
+ COPY app.py .
66
 
67
+ # Set CUDA environment variables
68
+ ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
69
+ ENV CUDA_VISIBLE_DEVICES=0
70
 
71
  # Run the application
72
  CMD ["python", "app.py"]