Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 62 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@

🔥 **ComfyUI with AMD ROCm support** - Run ComfyUI on AMD GPUs with optimized ROCm-compatible dependencies.

[![Docker Pulls](https://img.shields.io/docker/pulls/corundex/comfyui-rocm)](https://hub.docker.com/r/corundex/comfyui-rocm) [![ROCm](https://img.shields.io/badge/ROCm-6.4+-green)](https://rocm.docs.amd.com/) [![AMD GPU](https://img.shields.io/badge/AMD-RX%206000%2B-red)](https://www.amd.com/en/products/graphics/desktops/radeon.html)
[![Docker Pulls](https://img.shields.io/docker/pulls/corundex/comfyui-rocm)](https://hub.docker.com/r/corundex/comfyui-rocm) [![ROCm](https://img.shields.io/badge/ROCm-7.2+-green)](https://rocm.docs.amd.com/) [![AMD GPU](https://img.shields.io/badge/AMD-RX%206000%2B%20%7C%20RDNA4-red)](https://www.amd.com/en/products/graphics/desktops/radeon.html)

![ComfyUI Interface](Screenshot.png)
*ComfyUI running on AMD ROCm with sample workflow and generated landscape image*

## 📋 Version Information

- **Base Image**: `rocm/pytorch:rocm6.4.1_ubuntu24.04_py3.12_pytorch_release_2.6.0`
- **Python**: 3.12.10
- **PyTorch**: 2.6.0+git684f6f2
- **ROCm**: 6.4.43483-a187df25c
- **ComfyUI**: v0.3.43 (e18f53c, 2025-06-27)
- **Base Image**: `rocm/pytorch:rocm7.2.2_ubuntu24.04_py3.12_pytorch_release_2.10.0`
- **Python**: 3.12.x
- **PyTorch**: 2.10.0
- **ROCm**: 7.2.2
- **ComfyUI**: v0.19.3

## ✨ Key Features

- 🎨 **Node-based AI workflow** - Visual interface for creating complex AI pipelines
- 🔥 **AMD ROCm optimized** - Native AMD GPU acceleration with ROCm 6.4+
- 🔥 **AMD ROCm optimized** - Native AMD GPU acceleration with ROCm 7.2+
- 🆕 **RDNA4 native support** - RX 9060 XT / RX 9070 XT (gfx1200/gfx1201) work without workarounds
- 🔊 **torchaudio included** - Ships pre-built in the AMD ROCm base image (2.10.0+rocm7.2.2, enables audio/video custom nodes)
- 📦 **Smart model management** - Automatic downloads with configurable model sets
- 🧪 **Tested compatibility** - All dependencies verified on real AMD hardware
- 🎯 **Ready to use** - Pre-configured with sample workflows
- 🎯 **Ready to use** - Pre-configured with ComfyUI-Manager bundled
- 💾 **Persistent storage** - Models and outputs preserved across restarts


## 🚀 Quick Start

```bash
Expand All @@ -43,31 +44,34 @@ Access ComfyUI at: **http://localhost:8188**

## 📋 Requirements

| Component | Requirement |
| ---------- | ------------------------------------------ |
| **GPU** | AMD RX 6000/7000+ series with ROCm support |
| **VRAM** | 8GB minimum (16GB+ recommended) |
| **OS** | Linux (Ubuntu 24.04+ recommended) |
| **Docker** | Latest version with GPU support |
| **ROCm** | Drivers 6.4+ installed on host |
| Component | Requirement |
| ---------- | -------------------------------------------------------- |
| **GPU** | AMD RX 6000/7000/9000 series (RDNA2/3/4) with ROCm support |
| **VRAM** | 8GB minimum (16GB+ recommended) |
| **OS** | Linux (Ubuntu 24.04+ recommended) |
| **Docker** | Latest version with GPU support |
| **ROCm** | Drivers 7.2+ installed on host |

## 🔧 Setup Instructions

### 1. Install ROCm Drivers

```bash
# Ubuntu/Debian
curl -fsSL https://repo.radeon.com/rocm/rocm.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/rocm.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/6.4 jammy main" | sudo tee /etc/apt/sources.list.d/rocm.list
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/7.2 noble main" | sudo tee /etc/apt/sources.list.d/rocm.list
sudo apt update && sudo apt install rocm-dkms
sudo usermod -a -G render,video $USER
```

### 2. Verify ROCm Installation

```bash
rocm-smi # Should show your AMD GPU(s)
```

### 3. Run ComfyUI

```bash
docker run -d \
--name comfyui-rocm \
Expand All @@ -82,15 +86,15 @@ docker run -d \

Control model downloading with the `MODEL_DOWNLOAD` environment variable:

| Mode | Description | Models Included |
| ---------------- | ----------------------------- | ----------------------------------------------------- |
| `default` | Essential starter (4GB) | SD 1.5 |
| `common` | Comprehensive set (~30GB) | SD 1.5, SDXL, ControlNets, upscalers, VAE, embeddings |
| `realistic` | Photo-realistic models (~8GB) | Realistic Vision, DreamShaper, VAE |
| `photorealistic` | SDXL realistic (~12GB) | Juggernaut XL, RealVisXL |
| `artistic` | Creative/stylized (~2GB) | Deliberate v2 |
| `all` | Everything (~100GB) | All model sets combined |
| `none` | Skip downloads | Use existing models only |
| Mode | Description | Models Included |
| ---------------- | ------------------------------ | ------------------------------------------------------ |
| `default` | Essential starter (4GB) | SD 1.5 |
| `common` | Comprehensive set (~30GB) | SD 1.5, SDXL, ControlNets, upscalers, VAE, embeddings |
| `realistic` | Photo-realistic models (~8GB) | Realistic Vision, DreamShaper, VAE |
| `photorealistic` | SDXL realistic (~12GB) | Juggernaut XL, RealVisXL |
| `artistic` | Creative/stylized (~2GB) | Deliberate v2 |
| `all` | Everything (~100GB) | All model sets combined |
| `none` | Skip downloads | Use existing models only |

### Usage Examples

Expand Down Expand Up @@ -145,43 +149,64 @@ Run with: `docker compose up -d`
## ⚡ Performance & Hardware

### Tested Hardware
- **AMD Radeon RX 9060 XT** (16GB VRAM) ✅

- **AMD Radeon RX 9060 XT** (16GB VRAM, gfx1200/RDNA4) ✅
- **AMD Radeon RX 9070 XT** (16GB VRAM, gfx1201/RDNA4) ✅
- **AMD Radeon RX 7900 XTX** (24GB VRAM, gfx1100/RDNA3) ✅

### RDNA4 Support (RX 9000 Series)

ROCm 7.2.2 adds **native** support for RDNA4 GPUs (gfx1200 = RX 9060 XT, gfx1201 = RX 9070 XT).
No workarounds or `HSA_OVERRIDE_GFX_VERSION` flags are needed with this image.

If you are running ROCm < 7.x on RDNA4 hardware, you can set the following environment variable
as a workaround (forces RDNA3 kernel paths):

```bash
-e HSA_OVERRIDE_GFX_VERSION=11.0.0
```

### Performance Metrics

- **Generation Time**: ~30-60s for 512x512 images
- **VRAM Usage**: 4-8GB for basic operations
- **VRAM Usage**: 4-8GB for basic operations
- **Model Loading**: ~30-60s first time, cached afterward
- **Batch Processing**: Multiple images supported

### Tips

- Mount persistent volumes to avoid re-downloading models
- Start with `default` models, upgrade to larger sets as needed
- Use fast SSD storage for optimal performance

## 🔍 Troubleshooting

| Issue | Solution |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **Container won't start** | Check ROCm drivers: `rocm-smi` |
| **No GPU detected** | Verify container GPU access: `docker exec comfyui-rocm python -c "import torch; print(torch.cuda.is_available())"` |
| **Model download fails** | Check internet connection, disk space, and logs |
| **Out of memory** | Reduce batch size, use smaller models, ensure 8GB+ VRAM |
| **Models not found** | Verify downloads completed and file permissions |
| Issue | Solution |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| **Container won't start** | Check ROCm drivers: `rocm-smi` |
| **No GPU detected** | Verify container GPU access: `docker exec comfyui-rocm python -c "import torch; print(torch.cuda.is_available())"` |
| **Model download fails** | Check internet connection, disk space, and logs |
| **Out of memory** | Reduce batch size, use smaller models, ensure 8GB+ VRAM |
| **Models not found** | Verify downloads completed and file permissions |
| **`torchaudio` not found** | The base image ships torchaudio pre-built — if missing, verify your base image tag is correct |

## 📄 License & Credits

This project is licensed under GPL-3.0. See the [LICENSE](LICENSE) file for details.

### Third-Party Components

- **ComfyUI**: GPL-3.0 - [ComfyUI](https://github.com/comfyanonymous/ComfyUI)
- **PyTorch**: BSD 3-Clause - [PyTorch](https://pytorch.org/)
- **ROCm**: Various OSS licenses - [AMD ROCm](https://rocm.docs.amd.com/)

**Acknowledgments:**

- [ComfyUI](https://github.com/comfyanonymous/ComfyUI) - Node-based AI workflow interface
- [AMD ROCm](https://rocm.docs.amd.com/) - Open source GPU computing platform
- [AMD ROCm](https://rocm.docs.amd.com/) - Open source GPU computing platform
- [Griznah (Ole-Magnus Sæther)](https://github.com/Griznah) - ROCm 7.x update groundwork (PR #5)
- ROCm community for AMD GPU AI support

---

🔗 **Links:** [Docker Hub](https://hub.docker.com/r/corundex/comfyui-rocm) | [GitHub](https://github.com/corundex/comfyui-rocm) | [ComfyUI](https://github.com/comfyanonymous/ComfyUI)
🔗 **Links:** [Docker Hub](https://hub.docker.com/r/corundex/comfyui-rocm) | [GitHub](https://github.com/corundex/comfyui-rocm) | [ComfyUI](https://github.com/comfyanonymous/ComfyUI)
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ set -e
# Configuration
IMAGE_NAME="comfyui-rocm"
VERSION="${1:-latest}"
DETAILED_TAG="comfyui_0.3.43__rocm6.4.1_ubuntu24.04_py3.12_pytorch_2.6.0"
DETAILED_TAG="comfyui_0.19.3__rocm7.2.2_ubuntu24.04_py3.12_pytorch_2.10.0"

echo "🐳 Building ComfyUI ROCm Docker image..."
echo "📦 Tags: ${IMAGE_NAME}:${VERSION}, ${IMAGE_NAME}:${DETAILED_TAG}"
echo ""

# Build the image with both tags
echo "🔨 Building Docker image..."
docker build -f docker/Dockerfile -t "${IMAGE_NAME}:${VERSION}" -t "${IMAGE_NAME}:${DETAILED_TAG}" --progress=plain .
# Build the image with both tags using BuildKit (buildx)
echo "🔨 Building Docker image with BuildKit..."
docker buildx build -f docker/Dockerfile -t "${IMAGE_NAME}:${VERSION}" -t "${IMAGE_NAME}:${DETAILED_TAG}" --progress=plain --load .
63 changes: 45 additions & 18 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ROCm ComfyUI Dockerfile
# Based on AMD's official ROCm PyTorch container

FROM rocm/pytorch:rocm6.4.1_ubuntu24.04_py3.12_pytorch_release_2.6.0
FROM rocm/pytorch:rocm7.2.2_ubuntu24.04_py3.12_pytorch_release_2.10.0

# Set working directory
WORKDIR /workspace
Expand All @@ -11,33 +11,49 @@ RUN apt-get update && apt-get install -y \
git \
wget \
curl \
ffmpeg \
libgl1 \
libglib2.0-0 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Clone ComfyUI
RUN git clone https://github.com/comfyanonymous/ComfyUI.git
# Clone ComfyUI and checkout pinned version
RUN git clone https://github.com/comfyanonymous/ComfyUI.git \
&& cd ComfyUI \
&& git checkout v0.19.3

# Set ComfyUI as working directory
WORKDIR /workspace/ComfyUI

# Create necessary directories with separate commands
RUN mkdir -p /workspace/ComfyUI/models/checkpoints && \
mkdir -p /workspace/ComfyUI/models/vae && \
mkdir -p /workspace/ComfyUI/models/loras && \
mkdir -p /workspace/ComfyUI/models/embeddings && \
mkdir -p /workspace/ComfyUI/models/upscale_models && \
mkdir -p /workspace/ComfyUI/models/controlnet && \
mkdir -p /workspace/ComfyUI/output && \
mkdir -p /workspace/ComfyUI/input && \
mkdir -p /workspace/ComfyUI/custom_nodes
# Create necessary directories
RUN mkdir -p \
/workspace/ComfyUI/models/checkpoints \
/workspace/ComfyUI/models/vae \
/workspace/ComfyUI/models/loras \
/workspace/ComfyUI/models/embeddings \
/workspace/ComfyUI/models/upscale_models \
/workspace/ComfyUI/models/controlnet \
/workspace/ComfyUI/output \
/workspace/ComfyUI/input \
/workspace/ComfyUI/custom_nodes

# Install onnxruntime_migraphx — ROCm 7.x replacement for onnxruntime_rocm
# AMD renamed the package starting with ROCm 7.x; provides the same 'onnxruntime' Python namespace
RUN pip install --no-cache-dir \
"https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2.2/onnxruntime_migraphx-1.23.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl"

# Copy ROCm-tested requirements files
COPY docker/requirements_rocm.txt /workspace/

# Install Python dependencies using ROCm-compatible requirements
# These files have been tested on real AMD hardware and filter out packages that break ROCm
# Install Python dependencies using ROCm-compatible requirements.
# Note: torchaudio (2.10.0+rocm7.2.2) ships pre-built in the base image — pip
# satisfies the 'torchaudio' requirement from requirements.txt immediately.
RUN pip install --no-cache-dir -r /workspace/requirements_rocm.txt

# Install ComfyUI-Manager
RUN git clone --depth 1 https://github.com/Comfy-Org/ComfyUI-Manager.git custom_nodes/ComfyUI-Manager \
&& pip install --no-cache-dir -r custom_nodes/ComfyUI-Manager/requirements.txt

# Copy startup script, models config, and sample workflow
COPY docker/startup.sh /workspace/startup.sh
COPY docker/download_models.py /workspace/download_models.py
Expand All @@ -47,14 +63,26 @@ COPY docker/sample_workflow.json /workspace/ComfyUI/
# Make startup script executable
RUN chmod +x /workspace/startup.sh

# Verify ROCm stack is intact after all installs
RUN python - <<'PY'
import torch, torchvision
print(f"torch={torch.__version__} hip_available={torch.cuda.is_available()}")
print(f"torchvision={torchvision.__version__}")
try:
import torchaudio
print(f"torchaudio={torchaudio.__version__}")
except Exception as e:
print(f"torchaudio=unavailable ({e})")
PY

# Environment variables for model download behavior
# MODEL_DOWNLOAD options:
# "default" - Download basic SD 1.5 model (default)
# "all" - Download full model set (SD 1.5, SDXL, ControlNet, etc.)
# "realistic" - Download realistic photo models
# "realistic" - Download realistic photo models
# "none" - Skip all downloads, use existing models only
# Custom - Any section name from models.conf
ENV MODEL_DOWNLOAD=default
ENV MODEL_DOWNLOAD=none

# Expose ComfyUI port
EXPOSE 8188
Expand All @@ -65,4 +93,3 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \

# Use smart startup script that handles model downloads
CMD ["/workspace/startup.sh"]

Loading