FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True,max_split_size_mb:128 # Base OS tools + media stack + Python toolchain. RUN apt-get update && apt-get install -y --no-install-recommends \ python3.10 \ python3-pip \ python3.10-dev \ python3.10-venv \ ffmpeg \ git \ git-lfs \ ca-certificates \ curl \ build-essential \ pkg-config \ ninja-build \ libglib2.0-0 \ libgl1 \ && rm -rf /var/lib/apt/lists/* \ && ln -sf /usr/bin/python3.10 /usr/bin/python \ && ln -sf /usr/bin/pip3 /usr/bin/pip \ && git lfs install WORKDIR /app # Install project Python dependencies first for better layer caching. COPY requirements.txt /app/requirements.txt RUN python -m pip install --upgrade pip setuptools wheel \ && pip install --index-url https://download.pytorch.org/whl/cu121 torch torchvision torchaudio \ && pip install -r /app/requirements.txt \ && pip install -U accelerate safetensors # Ensure HunyuanVideo source exists in the image. ARG HUNYUAN_REPO=https://github.com/Tencent-Hunyuan/HunyuanVideo-1.5.git RUN if [ ! -f /app/HunyuanVideo-1.5/requirements.txt ]; then \ rm -rf /app/HunyuanVideo-1.5 && \ git clone --depth 1 "$HUNYUAN_REPO" /app/HunyuanVideo-1.5; \ fi # Install HunyuanVideo dependencies from upstream README guidance. RUN pip install -r /app/HunyuanVideo-1.5/requirements.txt \ && pip install --upgrade tencentcloud-sdk-python \ && pip install sgl-kernel==0.3.18 # Optional attention backends from Hunyuan docs. # Build with: --build-arg INSTALL_OPTIONAL_ATTENTION=1 ARG INSTALL_OPTIONAL_ATTENTION=0 RUN if [ "$INSTALL_OPTIONAL_ATTENTION" = "1" ]; then \ pip install flash-attn --no-build-isolation && \ git clone --depth 1 https://github.com/Tencent-Hunyuan/flex-block-attn.git /tmp/flex-block-attn && \ cd /tmp/flex-block-attn && git submodule update --init --recursive && python setup.py install && \ git clone --depth 1 https://github.com/cooper1637/SageAttention.git /tmp/SageAttention && \ cd /tmp/SageAttention && python setup.py install; \ fi COPY . . # Default pipeline entrypoint. CMD ["python", "run_video_pipeline.py"]