Files
comfyui-serverless/Dockerfile
Debian 9f71e6db57
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Limit SageAttention to A100/H100 due to cross-compile issues
The sm90 kernels use wgmma instructions that can't be compiled for
sm86/sm89 targets. Restricting to 8.0 (A100) and 9.0 (H100) only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 21:57:09 +00:00

153 lines
6.6 KiB
Docker

# ComfyUI RunPod Serverless - CUDA 12.8.1, Python 3.12, PyTorch 2.8.0
FROM nvidia/cuda:12.8.1-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=1
# CUDA environment
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
ENV LIBRARY_PATH=/usr/local/cuda/lib64/stubs:$LIBRARY_PATH
ENV PATH=/usr/local/cuda/bin:$PATH
# HuggingFace cache paths (will be symlinked to network volume)
ENV HF_HOME=/workspace/.cache/huggingface
ENV HF_HUB_ENABLE_HF_TRANSFER=1
ENV TRANSFORMERS_CACHE=/workspace/.cache/huggingface/transformers
# Install system dependencies and add deadsnakes PPA for Python 3.12
RUN apt-get update && apt-get install -y software-properties-common && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt-get update && apt-get install -y \
python3.12 \
python3.12-dev \
python3.12-venv \
python3-pip \
git \
git-lfs \
wget \
curl \
ffmpeg \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
build-essential \
ninja-build \
&& rm -rf /var/lib/apt/lists/*
# Set Python 3.12 as default and bootstrap pip
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1 && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 && \
python3.12 -m ensurepip --upgrade && \
python3.12 -m pip install --upgrade pip setuptools wheel
# Install PyTorch 2.8.0+cu128 and triton 3.4.0 in single layer
RUN pip install \
torch==2.8.0+cu128 \
torchvision==0.23.0+cu128 \
torchaudio==2.8.0+cu128 \
triton==3.4.0 \
--index-url https://download.pytorch.org/whl/cu128 && \
rm -rf /root/.cache/pip /tmp/*
# Install nunchaku from GitHub wheel
RUN pip install https://github.com/nunchaku-tech/nunchaku/releases/download/v1.0.2/nunchaku-1.0.2+torch2.8-cp312-cp312-linux_x86_64.whl
# Install key dependencies before SageAttention
COPY requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt && rm -rf /root/.cache/pip
# Compile SageAttention 2.2 from source with no build isolation
WORKDIR /tmp
ENV EXT_PARALLEL=2
ENV NVCC_APPEND_FLAGS="--threads 2"
ENV MAX_JOBS=4
# Target RunPod GPU architectures:
# 8.0 = A100, 9.0 = H100/H200
# Note: 8.6/8.9 excluded due to SageAttention sm90 kernel cross-compile issues
ENV TORCH_CUDA_ARCH_LIST="8.0;9.0"
RUN git clone https://github.com/thu-ml/SageAttention.git && \
cd SageAttention && \
git checkout 2aecfa8 && \
pip install --no-build-isolation . && \
cd / && rm -rf /tmp/SageAttention /root/.cache/pip
# Clone ComfyUI
WORKDIR /workspace
RUN git clone https://github.com/comfyanonymous/ComfyUI.git && \
cd ComfyUI && \
pip install -r requirements.txt
# Install custom nodes
WORKDIR /workspace/ComfyUI/custom_nodes
RUN git clone https://github.com/ltdrdata/ComfyUI-Manager.git && \
git clone https://github.com/jnxmx/ComfyUI_HuggingFace_Downloader.git && \
git clone https://github.com/kijai/ComfyUI-KJNodes.git && \
git clone https://github.com/kijai/ComfyUI-WanVideoWrapper.git && \
git clone https://github.com/Fannovel16/comfyui_controlnet_aux.git && \
git clone https://github.com/crystian/ComfyUI-Crystools.git && \
git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git && \
git clone https://github.com/willmiao/ComfyUI-Lora-Manager.git && \
git clone https://github.com/city96/ComfyUI-GGUF.git && \
git clone https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git && \
git clone https://github.com/nunchaku-tech/ComfyUI-nunchaku.git && \
git clone https://github.com/evanspearman/ComfyMath.git && \
git clone https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git && \
git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git && \
git clone https://github.com/yolain/ComfyUI-Easy-Use.git
# Install custom node dependencies (single layer)
RUN (cd ComfyUI-KJNodes && pip install -r requirements.txt || true) && \
(cd ComfyUI-WanVideoWrapper && pip install -r requirements.txt || true) && \
(cd comfyui_controlnet_aux && pip install -r requirements.txt || true) && \
(cd ComfyUI-VideoHelperSuite && pip install -r requirements.txt || true) && \
(cd ComfyUI-GGUF && pip install -r requirements.txt || true) && \
(cd ComfyUI-Frame-Interpolation && pip install -r requirements.txt || true) && \
(cd ComfyUI-nunchaku && pip install -r requirements.txt || true) && \
(cd ComfyUI-Easy-Use && pip install -r requirements.txt || true) && \
rm -rf /root/.cache/pip /tmp/*
# Download RIFE model for frame interpolation
RUN mkdir -p /workspace/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/ckpts/rife && \
wget -q -O /workspace/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation/ckpts/rife/rife47.pth \
https://github.com/styler00dollar/VSGAN-tensorrt-docker/releases/download/models/rife47.pth
# Create directories and symlinks to network volume
# RunPod mounts network volumes at /runpod-volume
# Models are stored in /runpod-volume/ComfyUI/models/ (matching standard ComfyUI layout)
WORKDIR /workspace/ComfyUI
RUN mkdir -p /runpod-volume/ComfyUI/models/checkpoints \
/runpod-volume/ComfyUI/models/loras \
/runpod-volume/ComfyUI/models/vae \
/runpod-volume/ComfyUI/models/controlnet \
/runpod-volume/ComfyUI/models/clip \
/runpod-volume/ComfyUI/models/upscale_models \
/runpod-volume/ComfyUI/models/diffusion_models \
/runpod-volume/ComfyUI/models/text_encoders \
/runpod-volume/.cache/huggingface \
/workspace/.cache
# Symlink model directories to /runpod-volume/ComfyUI/models
RUN rm -rf models/checkpoints && ln -s /runpod-volume/ComfyUI/models/checkpoints models/checkpoints && \
rm -rf models/loras && ln -s /runpod-volume/ComfyUI/models/loras models/loras && \
rm -rf models/vae && ln -s /runpod-volume/ComfyUI/models/vae models/vae && \
rm -rf models/controlnet && ln -s /runpod-volume/ComfyUI/models/controlnet models/controlnet && \
rm -rf models/clip && ln -s /runpod-volume/ComfyUI/models/clip models/clip && \
rm -rf models/upscale_models && ln -s /runpod-volume/ComfyUI/models/upscale_models models/upscale_models && \
rm -rf models/diffusion_models && ln -s /runpod-volume/ComfyUI/models/diffusion_models models/diffusion_models && \
rm -rf models/text_encoders && ln -s /runpod-volume/ComfyUI/models/text_encoders models/text_encoders
# Symlink HuggingFace cache
RUN ln -s /runpod-volume/.cache/huggingface /workspace/.cache/huggingface
# Copy handler and workflows
WORKDIR /workspace
COPY handler.py /workspace/handler.py
COPY workflows /workspace/workflows
# RunPod handler entrypoint
CMD ["python", "-u", "handler.py"]