feylur commited on
Commit
841af59
·
verified ·
1 Parent(s): 71f8089

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +83 -58
Dockerfile CHANGED
@@ -1,62 +1,87 @@
1
- # 1. Use a standard Python 3.10 image (matches HF Spaces)
2
- FROM python:3.10-slim
3
 
4
- # 2. Set the working directory inside the container
5
- WORKDIR /app
 
 
6
 
7
- # 3. Copy all your project files (app.py, CatVTON folder, etc.)
8
- COPY . .
9
 
10
- # 4. Install system dependencies needed for 'av' and 'opencv'
11
  RUN apt-get update && apt-get install -y \
12
- ffmpeg \
13
- libgl1 \
14
- && apt-get clean
15
-
16
- # 5. Run your Kaggle installation script in smaller, logical steps
17
- # This prevents the "Out of Memory" (Exit 137) error.
18
-
19
- # --- Step 5a: Uninstall and install core scientific stack
20
- RUN --mount=type=cache,target=/root/.cache/pip \
21
- pip uninstall -y numpy scipy scikit-learn matplotlib huggingface-hub accelerate peft && \
22
- pip install numpy==1.26.4 && \
23
- pip install scipy==1.11.4 && \
24
- pip install scikit-learn==1.3.2 && \
25
- pip install matplotlib==3.7.2
26
-
27
- # --- Step 5b: Install PyTorch stack (one-by-one to save RAM)
28
- RUN --mount=type=cache,target=/root/.cache/pip \
29
- pip install torch==2.1.0 --index-url https://download.pytorch.org/whl/cu118
30
-
31
- RUN --mount=type=cache,target=/root/.cache/pip \
32
- pip install torchvision==0.16.0 --index-url https://download.pytorch.org/whl/cu118
33
-
34
- RUN --mount=type=cache,target=/root/.cache/pip \
35
- pip install torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
36
-
37
- # --- Step 5c: Install Hugging Face stack
38
- RUN --mount=type=cache,target=/root/.cache/pip \
39
- pip install huggingface_hub==0.20.0 && \
40
- pip install safetensors==0.4.1 && \
41
- pip install diffusers==0.25.0 && \
42
- pip install transformers==4.36.0 && \
43
- pip install accelerate==0.28.0 && \
44
- pip install peft==0.8.2
45
-
46
- # --- Step 5d: Install Vision/Utility stack
47
- RUN --mount=type=cache,target=/root/.cache/pip \
48
- pip install opencv-python-headless==4.8.1.78 pillow==11.3.0 && \
49
- pip install fvcore==0.1.5.post20221221 iopath==0.1.10 av==16.0.1 omegaconf==2.3.0
50
-
51
- # --- Step 5e: Install Gradio stack
52
- RUN --mount=type=cache,target=/root/.cache/pip \
53
- pip install ipywidgets==8.1.5 && \
54
- pip install gradio==4.31.0
55
-
56
- # 6. CRITICAL: Re-run your "Step 7" to lock the hub version
57
- # This runs as its own step to guarantee it wins any conflicts
58
- RUN --mount=type=cache,target=/root/.cache/pip \
59
- pip install --force-reinstall huggingface_hub==0.20.0 --no-deps
60
-
61
- # 7. Tell the container what command to run to start your Gradio app
62
- CMD ["gradio", "app.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use CUDA-enabled base image for GPU support
2
+ FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
3
 
4
+ # Set environment variables
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+ ENV PYTHONUNBUFFERED=1
7
+ ENV CUDA_HOME=/usr/local/cuda-11.8
8
 
9
+ WORKDIR /app
 
10
 
11
+ # Install system dependencies
12
  RUN apt-get update && apt-get install -y \
13
+ python3.10 \
14
+ python3-pip \
15
+ git \
16
+ wget \
17
+ libglib2.0-0 \
18
+ libsm6 \
19
+ libxext6 \
20
+ libxrender-dev \
21
+ libgomp1 \
22
+ libgl1-mesa-glx \
23
+ && rm -rf /var/lib/apt/lists/*
24
+
25
+ # Create symbolic links for python
26
+ RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \
27
+ ln -sf /usr/bin/pip3 /usr/bin/pip
28
+
29
+ # Upgrade pip
30
+ RUN pip install --upgrade pip setuptools wheel
31
+
32
+ # ===== CRITICAL: Install packages in EXACT ORDER to maintain compatibility =====
33
+
34
+ # Step 1: Install NumPy 1.26.4 FIRST (LOCKED)
35
+ RUN pip install --no-cache-dir numpy==1.26.4
36
+
37
+ # Step 2: Install compatible scientific packages
38
+ RUN pip install --no-cache-dir \
39
+ scipy==1.11.4 \
40
+ scikit-learn==1.3.2 \
41
+ matplotlib==3.7.2
42
+
43
+ # Step 3: Install PyTorch with CUDA 11.8 support
44
+ RUN pip install --no-cache-dir \
45
+ torch==2.1.0 \
46
+ torchvision==0.16.0 \
47
+ torchaudio==2.1.0 \
48
+ --index-url https://download.pytorch.org/whl/cu118
49
+
50
+ # Step 4: Install AI/ML packages with LOCKED versions
51
+ RUN pip install --no-cache-dir \
52
+ huggingface_hub==0.20.0 \
53
+ safetensors==0.4.1 \
54
+ diffusers==0.25.0 \
55
+ transformers==4.36.0 \
56
+ accelerate==0.28.0 \
57
+ peft==0.8.2
58
+
59
+ # Step 5: Install computer vision and utility packages
60
+ RUN pip install --no-cache-dir \
61
+ opencv-python-headless==4.8.1.78 \
62
+ pillow
63
+
64
+ # Step 6: Install additional dependencies
65
+ RUN pip install --no-cache-dir \
66
+ fvcore \
67
+ iopath \
68
+ av \
69
+ omegaconf
70
+
71
+ # Step 7: Install Gradio for web interface (Hugging Face Spaces)
72
+ RUN pip install --no-cache-dir gradio
73
+
74
+ # Step 8: Force reinstall huggingface_hub to lock version (prevent auto-upgrades)
75
+ RUN pip install --force-reinstall --no-cache-dir huggingface_hub==0.20.0 --no-deps
76
+
77
+ # Copy application code
78
+ COPY . /app
79
+
80
+ # Create necessary directories
81
+ RUN mkdir -p /app/models /app/outputs
82
+
83
+ # Expose port for Hugging Face Spaces (default: 7860)
84
+ EXPOSE 7860
85
+
86
+ # Set the entrypoint
87
+ CMD ["python", "app.py"]