ai_video / Dockerfile
callernode's picture
Upload 4 files
be19bb3 verified
Raw History Blame Contribute Delete
2.4 kB
# Wan 2.2 Text-to-Video Backend β€” Dockerfile (custom GPU server)
#
# For Hugging Face Spaces you do NOT need this Dockerfile β€” just upload
# `app.py`, `requirements.txt`, and `README.md` (with `sdk: gradio` in the
# front matter). HF Spaces pre-installs torch 2.8.0 + gradio + spaces.
#
# Use this Dockerfile when you want to deploy to a custom GPU server:
# - RunPod / Lambda Labs / Vast.ai / AWS EC2 with GPU
# - Any container orchestrator that can attach a CUDA-capable GPU
#
# Build & run:
# docker build -t wan22-backend .
# docker run --gpus all -p 7860:7860 \
# -e HF_TOKEN=hf_xxx \
# -e WAN_MODEL_ID=Wan-AI/Wan2.1-T2V-1.3B-Diffusers \
# wan22-backend
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
# Prevent Python from buffering stdout (so logs appear immediately)
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.10 python3-pip python3.10-venv \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \
ln -sf /usr/bin/python3.10 /usr/bin/python3
WORKDIR /app
# ─── Step 1: install torch + torchvision separately ────────────────────────
# Use the official PyTorch CUDA 12.1 wheel index. These versions are paired:
# torch 2.4.0 ↔ torchvision 0.19.0
# (For Hugging Face Spaces, torch is pre-installed and you do NOT need this
# step β€” the HF template handles it.)
RUN pip install --upgrade pip && \
pip install --no-cache-dir \
torch==2.4.0 \
torchvision==0.19.0 \
--index-url https://download.pytorch.org/whl/cu121
# ─── Step 2: install the rest of the deps ─────────────────────────────────
# requirements.txt does NOT pin torch / torchvision (so it can also be used
# by HF Spaces where torch is pre-installed). For this Dockerfile path, torch
# was already installed in Step 1 above.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ─── Step 3: copy the app ─────────────────────────────────────────────────
COPY app.py .
EXPOSE 7860
ENV PORT=7860
CMD ["python", "app.py"]