# Use CUDA-enabled base image for GPU support FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 # Set environment variables ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 ENV CUDA_HOME=/usr/local/cuda-11.8 WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ python3.10 \ python3-pip \ git \ wget \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ libgl1-mesa-glx \ && rm -rf /var/lib/apt/lists/* # Create symbolic links for python RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \ ln -sf /usr/bin/pip3 /usr/bin/pip # Upgrade pip RUN pip install --upgrade pip setuptools wheel # ===== CRITICAL: Install packages in EXACT ORDER to maintain compatibility ===== # Step 1: Install NumPy 1.26.4 FIRST (LOCKED) RUN pip install --no-cache-dir numpy==1.26.4 # Step 2: Install compatible scientific packages RUN pip install --no-cache-dir \ scipy==1.11.4 \ scikit-learn==1.3.2 \ matplotlib==3.7.2 # Step 3: Install PyTorch with CUDA 11.8 support RUN pip install --no-cache-dir \ torch==2.1.0 \ torchvision==0.16.0 \ torchaudio==2.1.0 \ --index-url https://download.pytorch.org/whl/cu118 # Step 4: Install AI/ML packages with LOCKED versions RUN pip install --no-cache-dir \ huggingface_hub==0.20.0 \ safetensors==0.4.1 \ diffusers==0.25.0 \ transformers==4.36.0 \ accelerate==0.28.0 \ peft==0.8.2 # Step 5: Install computer vision and utility packages RUN pip install --no-cache-dir \ opencv-python-headless==4.8.1.78 \ pillow # Step 6: Install additional dependencies RUN pip install --no-cache-dir \ fvcore \ iopath \ av \ omegaconf # Step 7: Install Gradio COMPATIBLE with huggingface_hub==0.20.0 # Gradio 4.x requires newer huggingface_hub, so we use Gradio 3.x RUN pip install --no-cache-dir gradio==3.50.2 # Step 8: Install additional web dependencies RUN pip install --no-cache-dir \ fastapi \ uvicorn # Copy application code COPY . /app # Create necessary directories RUN mkdir -p /app/models /app/outputs # Expose port for Hugging Face Spaces (default: 7860) EXPOSE 7860 # Set the entrypoint CMD ["python", "app.py"]