Files
2026-02-10 23:05:32 -05:00

111 lines
3.5 KiB
Docker

# ROCm 7.2 + Ubuntu 24.04 + Python 3.12 + PyTorch 2.8.0 + ComfyUI
FROM rocm/dev-ubuntu-24.04:7.2-complete
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
LD_LIBRARY_PATH=/opt/rocm/lib:/opt/rocm/miopen/lib
# System dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-venv \
python3-pip \
git \
ca-certificates \
wget \
migraphx \
miopen-hip \
rocsolver \
libssl-dev \
libffi-dev && \
rm -rf /var/lib/apt/lists/*
# Ensure python3.12 is the default python / pip
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
# Create and prepare virtual environment
RUN python -m venv /opt/comfyui-venv && \
/opt/comfyui-venv/bin/pip install --upgrade pip
# Install specific ROCm 7.2 wheels for torch, torchaudio, triton, and torchvision
# Use --no-deps to avoid pip trying to resolve triton to a different version
RUN /opt/comfyui-venv/bin/pip install \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.8.0%2Brocm7.2.0.lw.gitbf943426-cp312-cp312-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.4.0%2Brocm7.2.0.git0cace8d2-cp312-cp312-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchaudio-2.8.0%2Brocm7.2.0.git6e1c7fe9-cp312-cp312-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp312-cp312-linux_x86_64.whl
# Install common Python-level dependencies that PyTorch and friends rely on
RUN /opt/comfyui-venv/bin/pip install \
filelock \
typing-extensions \
sympy \
networkx \
jinja2 \
fsspec \
packaging
# Optionally install flash-attention (requires HIP GPU at build time)
ARG BUILD_FLASH_ATTENTION=true
RUN if [ "$BUILD_FLASH_ATTENTION" = "true" ]; then \
echo "Building flash-attention with HIP support" && \
git clone https://github.com/Dao-AILab/flash-attention.git /opt/flash-attention && \
cd /opt/flash-attention && \
/opt/comfyui-venv/bin/pip install ninja && \
FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE FLASH_ATTENTION_SKIP_CK_BUILD=FALSE \
/opt/comfyui-venv/bin/python setup.py install; \
else \
echo "Skipping flash-attention build (BUILD_FLASH_ATTENTION=$BUILD_FLASH_ATTENTION)"; \
fi
# Install ComfyUI
RUN git clone https://github.com/Comfy-Org/ComfyUI.git /opt/ComfyUI
WORKDIR /opt/ComfyUI
RUN /opt/comfyui-venv/bin/pip install --upgrade pip && \
/opt/comfyui-venv/bin/pip install \
comfyui-frontend-package==1.38.13 \
comfyui-workflow-templates==0.8.38 \
comfyui-embedded-docs==0.4.1 \
torchsde \
"numpy>=1.25.0" \
einops \
"transformers>=4.50.3" \
"tokenizers>=0.13.3" \
sentencepiece \
"safetensors>=0.4.2" \
"aiohttp>=3.11.8" \
"yarl>=1.18.0" \
pyyaml \
Pillow \
scipy \
tqdm \
psutil \
alembic \
SQLAlchemy \
"av>=14.2.0" \
"comfy-kitchen>=0.2.7" \
"comfy-aimdo>=0.1.8" \
requests \
"kornia>=0.7.1" \
spandrel \
"pydantic~=2.0" \
"pydantic-settings~=2.0"
EXPOSE 8188
ENV PATH="/opt/comfyui-venv/bin:${PATH}"
CMD ["python", "main.py", "--listen", "0.0.0.0", "--port", "8188"]