| # ============================================================================= | |
| # HF Spaces Docker image for daVinci-MagiHuman | |
| # Hardware: A100-80GB (recommended) | |
| # ============================================================================= | |
| FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV GRADIO_SERVER_NAME=0.0.0.0 | |
| ENV GRADIO_SERVER_PORT=7860 | |
| # System deps | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3.12 python3.12-dev python3.12-venv python3-pip \ | |
| git ffmpeg libsndfile1 ninja-build && \ | |
| rm -rf /var/lib/apt/lists/* && \ | |
| ln -sf /usr/bin/python3.12 /usr/bin/python && \ | |
| ln -sf /usr/bin/python3.12 /usr/bin/python3 | |
| WORKDIR /app | |
| # --------------------------------------------------------------------------- | |
| # PyTorch (must be installed first — MagiCompiler build depends on it) | |
| # --------------------------------------------------------------------------- | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir torch torchvision torchaudio \ | |
| --index-url https://download.pytorch.org/whl/cu124 | |
| # --------------------------------------------------------------------------- | |
| # Local packages: MagiCompiler + stable-audio whl | |
| # --------------------------------------------------------------------------- | |
| COPY pkgs/ pkgs/ | |
| RUN pip install -e ./pkgs/MagiCompiler \ | |
| --no-build-isolation --config-settings editable_mode=compat && \ | |
| pip install --no-cache-dir pkgs/magife_stable_audio_open-1.0.0+mav.1-py3-none-any.whl | |
| # --------------------------------------------------------------------------- | |
| # Flash Attention (pre-built wheel for CUDA 12.4 + PyTorch 2.9) | |
| # --------------------------------------------------------------------------- | |
| RUN pip install --no-cache-dir flash-attn --no-build-isolation | |
| # --------------------------------------------------------------------------- | |
| # Project Python dependencies | |
| # --------------------------------------------------------------------------- | |
| COPY requirements.txt requirements-nodeps.txt ./ | |
| RUN pip install --no-cache-dir -r requirements.txt && \ | |
| pip install --no-cache-dir --no-deps -r requirements-nodeps.txt && \ | |
| pip install --no-cache-dir gradio huggingface_hub soundfile | |
| # --------------------------------------------------------------------------- | |
| # Project code | |
| # --------------------------------------------------------------------------- | |
| COPY inference/ inference/ | |
| COPY example/ example/ | |
| COPY app.py . | |
| # Model weights are downloaded at runtime from HF Hub. | |
| # Enable "Persistent storage" in Space settings so /data survives restarts. | |
| ENV MODEL_ROOT=/data/models | |
| EXPOSE 7860 | |
| CMD ["python", "app.py"] | |