# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04 RUN apt-get update && apt-get install -y \ python3.10 python3.10-dev python3-pip \ ffmpeg libsm6 libxext6 libgl1 \ git libsndfile1 \ && rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 RUN python -m pip install --upgrade pip RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" ENV HF_HOME=/home/user/.cache/huggingface ENV PYTHONUNBUFFERED=1 WORKDIR /app # Clone official Wan2.2 RUN git clone https://github.com/Wan-Video/Wan2.2.git /app/Wan2.2 # Patch script COPY --chown=user ./patch_wan_init.py /tmp/patch_wan_init.py # PyTorch RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 # All deps (flash_attn may fail, that's ok) RUN cd /app/Wan2.2 && (pip install --no-cache-dir -r requirements.txt 2>/dev/null; exit 0) RUN pip install --no-cache-dir \ diffusers opencv-python easydict decord einops ftfy "numpy>=1.23.5,<2" \ transformers accelerate tokenizers peft \ tqdm "imageio[ffmpeg]" imageio-ffmpeg sentencepiece \ protobuf soundfile librosa dashscope # Apply patches RUN python3 /tmp/patch_wan_init.py # Copy app COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt COPY --chown=user ./app.py app.py COPY --chown=user ./README.md README.md CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]