# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker # Use NVIDIA PyTorch base image for GPU support FROM pytorch/pytorch:2.1.0-cuda12.1-cudnn8-devel # Create user as required by HF Spaces RUN useradd -m -u 1000 user # Install system dependencies RUN apt-get update && apt-get install -y \ git \ wget \ curl \ libgl1-mesa-glx \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ libgoogle-perftools4 \ libtcmalloc-minimal4 \ ffmpeg \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Switch to user USER user # Set environment variables for user ENV PATH="/home/user/.local/bin:$PATH" ENV PYTHONPATH=/app ENV GRADIO_SERVER_NAME=0.0.0.0 ENV GRADIO_SERVER_PORT=7860 # Set working directory WORKDIR /app # Copy requirements and install Python dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy application code COPY --chown=user . /app # Create necessary directories RUN mkdir -p pretrained_models outputs # Expose port (required by HF Spaces to be 7860) EXPOSE 7860 # Start the application CMD ["python", "app.py"]