fffiloni commited on
Commit
01ebd43
·
verified ·
1 Parent(s): c3584e1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -46
Dockerfile CHANGED
@@ -1,69 +1,62 @@
1
- # --- Base Image ---
2
  FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
3
 
4
- # --- Non-interactive environment ---
 
 
 
 
 
5
  ENV DEBIAN_FRONTEND=noninteractive
6
 
7
- # --- System Dependencies ---
8
- RUN apt-get update && apt-get install -y \
9
- build-essential \
10
- git \
11
- libgl1-mesa-glx \
12
- libglib2.0-0 \
13
- unzip \
14
- wget \
15
- && rm -rf /var/lib/apt/lists/*
16
 
17
- # --- Upgrade pip ---
18
- RUN pip install --upgrade pip
19
 
20
- # --- Create a non-root user ---
 
 
21
  RUN useradd -m -u 1000 user
 
22
  USER user
23
- WORKDIR /home/user/app
24
-
25
- # --- Environment Variables for caches and Gradio ---
26
  ENV HOME=/home/user \
27
- COQUI_TTS_CACHE=/home/user/.cache/tts \
28
- XDG_CACHE_HOME=/home/user/.cache \
29
- HF_HOME=/home/user/.cache \
30
- TRANSFORMERS_CACHE=/home/user/.cache \
31
- TORCH_HOME=/home/user/.cache \
32
- OMP_NUM_THREADS=1 \
33
  PYTHONUNBUFFERED=1 \
34
  GRADIO_ALLOW_FLAGGING=never \
35
  GRADIO_NUM_PORTS=1 \
36
  GRADIO_SERVER_NAME=0.0.0.0 \
37
  GRADIO_THEME=huggingface \
38
  GRADIO_SHARE=False \
39
- SYSTEM=spaces \
40
- CUDA_HOME=/usr/local/cuda \
41
- PATH=/home/user/.local/bin:$PATH \
42
- LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH} \
43
- LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LIBRARY_PATH} \
44
- CUDA_DEVICE_ORDER=PCI_BUS_ID \
45
- CUDA_VISIBLE_DEVICES=0
46
 
47
- # --- Copy app sources ---
48
- COPY --chown=user:user . .
49
 
50
- # --- Make app directories writable ---
51
- RUN mkdir -p /home/user/.cache /home/user/.local /home/user/app/bark_voices \
52
- && chmod -R 777 /home/user/.cache /home/user/.local /home/user/app/bark_voices
53
 
54
- # --- Hack: redirect /root accesses to /home/user ---
55
  USER root
56
- RUN rm -rf /root && ln -s /home/user /root
57
  USER user
58
 
59
- # --- Manual Bark model download to prevent pickle errors ---
60
- RUN mkdir -p /home/user/.cache/tts_models/multilingual/multi-dataset \
61
- && cd /home/user/.cache/tts_models/multilingual/multi-dataset \
62
- && wget -O bark.zip "https://huggingface.co/coqui/tts_models/multilingual/multi-dataset/bark/resolve/main/bark.zip" \
63
- && unzip bark.zip && rm bark.zip
64
-
65
- # --- Install Python dependencies ---
66
  RUN pip install --use-feature=fast-deps -r requirements.txt gradio
67
 
68
- # --- Run the app ---
69
- CMD ["python", "app.py"]
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official PyTorch image with CUDA support as the base image
2
  FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
3
 
4
+ RUN apt-get update && apt-get install -y build-essential
5
+
6
+ # Install a specific version of pip (e.g., 20.2.4)
7
+ RUN pip install --upgrade pip
8
+
9
+ # Install Git and system libraries required for OpenGL without interactive prompts
10
  ENV DEBIAN_FRONTEND=noninteractive
11
 
12
+ # Install Git, OpenGL libraries, and libglib2.0
13
+ RUN apt-get update && apt-get install -y git libgl1-mesa-glx libglib2.0-0
 
 
 
 
 
 
 
14
 
15
+ # Set the pip resolver to "legacy"
16
+ RUN pip config set global.resolver legacy
17
 
18
+ #RUN apt-get update && apt-get install -y ninja-build
19
+
20
+ # Set up a new user named "user" with user ID 1000
21
  RUN useradd -m -u 1000 user
22
+ # Switch to the "user" user
23
  USER user
24
+ # Set environment variables
 
 
25
  ENV HOME=/home/user \
26
+ CUDA_HOME=/usr/local/cuda \
27
+ PATH=/home/user/.local/bin:$PATH \
28
+ LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} \
29
+ LIBRARY_PATH=${CUDA_HOME}/lib64/stubs:${LIBRARY_PATH} \
30
+ PYTHONPATH=$HOME/app \
 
31
  PYTHONUNBUFFERED=1 \
32
  GRADIO_ALLOW_FLAGGING=never \
33
  GRADIO_NUM_PORTS=1 \
34
  GRADIO_SERVER_NAME=0.0.0.0 \
35
  GRADIO_THEME=huggingface \
36
  GRADIO_SHARE=False \
37
+ SYSTEM=spaces
 
 
 
 
 
 
38
 
39
+ # Set the working directory to the user's home directory
40
+ WORKDIR $HOME/app
41
 
42
+ COPY . .
 
 
43
 
 
44
  USER root
45
+ RUN chmod -R 777 $HOME/app/bark_voices
46
  USER user
47
 
48
+ # Install dependencies
49
+ # Use the new pip resolver and always take the latest version if not specified
 
 
 
 
 
50
  RUN pip install --use-feature=fast-deps -r requirements.txt gradio
51
 
52
+
53
+ # Update package lists and install other dependencies as needed
54
+ # Ensure that CUDA components are correctly installed and configured
55
+ # Install any other required packages
56
+
57
+ # Set the environment variable to specify the GPU device
58
+ ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
59
+ ENV CUDA_VISIBLE_DEVICES=0
60
+
61
+ # Run your app.py script
62
+ CMD ["python", "app.py"]