DEV Community

Cover image for How to Run Stable Diffusion & ComfyUI on AMD GPUs: Complete ROCm Setup Guide
OJO Miracle
OJO Miracle

Posted on

How to Run Stable Diffusion & ComfyUI on AMD GPUs: Complete ROCm Setup Guide

Learn how to run Stable Diffusion and ComfyUI on AMD GPUs using ROCm. Step-by-step guide to fixing black images, PyTorch errors, and VRAM limits.

Excerpt: Most Stable Diffusion guides assume you have an NVIDIA GPU. This one does not. This guide covers the real-world process of getting ComfyUI and Stable Diffusion running reliably on AMD hardware, from ROCm installation to diagnosing black images and phantom CUDA errors.


Introduction

Most local AI image generation documentation has a silent assumption baked into it: the user has an NVIDIA graphics card. The commands reference CUDA, the performance tips assume cuDNN, and the troubleshooting steps tell you to check your NVIDIA driver. If you own an AMD GPU, you have probably discovered that following these guides feels like translating a conversation in a language you only half understand. The steps look familiar, but the errors are different, the performance characteristics do not match the descriptions, and the community knowledge is thinner on the ground.

This creates a specific kind of frustration. You have a capable GPU sitting in your machine. It handles modern games without issue. Yet when you try to generate an image with Stable Diffusion, you might get a black square, a cryptic memory error, or a crash that no amount of generic googling seems to resolve. The common advice in forums is often to simply buy an NVIDIA card. That advice is not wrong for every situation, but it is incomplete and ignores the fact that many people already own AMD hardware and want to use it.

I wrote this guide because the AMD path is real, functional, and increasingly practical, but it requires a different mental model than the NVIDIA path. It requires understanding what ROCm actually does, why PyTorch can be installed in a way that does not recognize your GPU, and why memory optimization flags that work on CUDA do not always translate to HIP. This is not a simplified tutorial. It is a technical walkthrough for people who want to understand their system well enough to fix it when it breaks.

After working through this guide, you should be able to install ROCm and PyTorch correctly on your AMD system, configure ComfyUI for reliable image generation, diagnose black images systematically, understand whether a memory error is real or a configuration artifact, and optimize your workflows for the VRAM you actually have. You will also learn when the effort is not worth it and when moving to NVIDIA hardware is the more rational choice.


AMD GPU Compatibility: What You Need to Know First

The first source of confusion for AMD users is compatibility. NVIDIA users have a relatively simple situation: if your card supports CUDA and has enough VRAM, it will work with Stable Diffusion. AMD users face a matrix of GPU generations, ROCm support levels, operating system differences, and unofficial community patches. The official list of supported GPUs on ROCm is much shorter than the list of GPUs that actually work in practice.

The key architectural distinction matters. AMD has released several GPU generations: GCN (Graphics Core Next), RDNA 1, RDNA 2, RDNA 3, and the newer RDNA 4 architectures. ROCm was originally developed for AMD's datacenter and workstation cards, specifically the Instinct and Radeon Pro lines. Consumer Radeon cards have historically been a lower priority, and official support has been uneven. If you are currently selecting hardware for your workstation, review this comprehensive analysis of the best AMD GPUs for AI and machine learning in 2026 to understand where consumer cards fall on the performance spectrum.

  • RDNA 2 cards: The Radeon RX 6000 series cards have received increasingly usable ROCm support on Linux. The RX 6800, 6800 XT, and 6900 XT are commonly reported to work well with Stable Diffusion under Linux with recent ROCm versions. The RX 6700 XT and 6600 XT are also functional, though with more limited VRAM they constrain the types of models you can run comfortably.
  • RDNA 3 cards: The RX 7000 series initially launched with limited ROCm support. Over time, support has improved, particularly on Linux. The RX 7900 XTX and 7900 XT are now reasonably well-supported and offer significant compute throughput for their price. The RX 7600 and 7700 series are more constrained by VRAM and have had spottier support, but still function in many configurations.
  • RDNA 4 cards: The newest generation cards are rapidly evolving in terms of software support. Check the official AMD ROCm documentation and recent PyTorch release notes before attempting a full installation. Community reports are often ahead of official documentation, but they can also be unreliable.
  • Older GCN cards: RX 580 or Vega series cards are generally not practical for modern Stable Diffusion. They may technically run under some ROCm versions, but performance is poor, the memory architecture is dated, and the software stack is fragile. The practical cutoff for a usable experience is RDNA 2 or newer.

Linux vs Windows

On Windows, ROCm support has historically been incomplete or unofficial. For a long time, running Stable Diffusion on an AMD GPU on Windows meant using DirectML, which worked but was slower and less feature-complete than the CUDA path. More recently, AMD has made progress on Windows ROCm support, but it is not at parity with Linux.

The practical recommendation is this: if you are serious about running Stable Diffusion on an AMD GPU, use Linux. Ubuntu and its derivatives have the most tested ROCm support. Other distributions work, but you may need to do more manual configuration. If you are on Windows and cannot or will not switch, you have options, but they are more fragile and you should expect additional troubleshooting.

VRAM Requirements

VRAM is the single most important hardware constraint for local image generation. It determines the maximum resolution you can generate at, the maximum batch size, whether you can load larger models like SDXL, and whether you can use extensions like ControlNet without constant memory errors.

Here is a practical breakdown of VRAM requirements for different use cases:

VRAM SD 1.5 SDXL ControlNet High-Res Workflows
4 GB Tight, works with aggressive optimization Not practical Not recommended No
6 GB Comfortable for basic use Very tight, requires heavy optimization Possible with limited models Limited
8 GB Comfortable Workable with optimization Possible Yes with care
12 GB Comfortable Comfortable Comfortable Yes
16 GB+ Excellent Excellent Excellent Yes

Compatibility Overview

GPU Generation Example Cards ROCm Support Practicality for Stable Diffusion
GCN RX 580, Vega 56 Minimal, aging Not recommended
RDNA 1 RX 5700 XT Experimental Marginal, high effort
RDNA 2 RX 6800 XT, 6900 XT Good on Linux Recommended for existing owners
RDNA 2 RX 6600 XT, 6700 XT Good on Linux Recommended with VRAM constraints
RDNA 3 RX 7900 XTX, 7900 XT Good on Linux Recommended for existing owners
RDNA 3 RX 7600, 7700 XT Fair on Linux Workable, VRAM constrained
RDNA 4 RX 9070 XT Evolving Check current support status

Official compatibility lists and real-world compatibility are not the same thing. Many GPUs that are not on AMD's official ROCm support list work perfectly well for Stable Diffusion. Conversely, some officially supported configurations fail in practice due to kernel version mismatches or PyTorch build issues.


How the AMD Stable Diffusion Stack Actually Works

Understanding the software stack is essential for effective troubleshooting. Knowing which layer is responsible saves hours of random experimentation when something breaks.

The architecture flows through the following layers:

Stable Diffusion Model / ComfyUI Workflow
                    |
             ComfyUI (Python)
                    |
             PyTorch (Python)
                    |
        ROCm / HIP runtime (C/C++)
                    |
           AMD Kernel Driver
                    |
              AMD GPU
Enter fullscreen mode Exit fullscreen mode

Each layer performs a specific job:

  • ComfyUI: The node-based interface that orchestrates the workflow. It loads the model, runs the sampler, manages conditioning, applies VAE decoding, and handles extensions. ComfyUI calls PyTorch functions rather than talking directly to hardware.
  • PyTorch: The machine learning framework providing tensor operations and model execution. PyTorch schedules computation. The ROCm backend is what AMD users rely on. Installing the ROCm build rather than the CUDA build is critical.
  • ROCm: AMD's open-source platform for GPU computing, providing runtime libraries, device drivers, and tools. ROCm includes HIP, AMD's CUDA equivalent, which functions as a translation layer letting CUDA-like code run on AMD hardware.
  • AMD Kernel Driver: The lowest layer managing hardware access, memory allocation, and basic GPU functionality. On Linux, this is the amdgpu driver inside the mainline kernel.

Why CUDA Tutorials Cause Problems

Most Stable Diffusion tutorials assume CUDA. They tell you to install PyTorch with CUDA support, use CUDA-specific flags like --xformers, and troubleshoot using nvidia-smi.

When following these instructions on an AMD system, you might install a PyTorch build that cannot see your GPU, install packages requiring missing CUDA libraries, apply ineffective optimization flags, or see CUDA error messages generated by software written exclusively for NVIDIA. The solution is to use the equivalent ROCm/HIP approach.


Installing ROCm for Stable Diffusion

The installation process requires precision. For deeper tuning details beyond this section, check out this guide on PyTorch on AMD GPUs: the complete ROCm setup and tuning guide.

Linux Installation

Before starting, verify your Linux kernel version against AMD ROCm release notes.

Step 1: Verify GPU Recognition
Run lspci to list PCI devices and confirm your AMD GPU is visible:

lspci | grep -i 'amd'
Enter fullscreen mode Exit fullscreen mode

Output should resemble:
03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 21 [Radeon RX 6800 XT]

Step 2: Check Kernel Compatibility
Check your kernel version:

uname -r
Enter fullscreen mode Exit fullscreen mode

Verify that your target ROCm version supports this kernel. If your kernel is too new, boot an older kernel or wait for a ROCm update.

Step 3: Install ROCm
On Ubuntu, use AMD's official repository:

# Add the AMD ROCm repository
wget [https://repo.radeon.com/amdgpu-install/latest/ubuntu/jammy/amdgpu-install_6.0.60002-1_all.deb](https://repo.radeon.com/amdgpu-install/latest/ubuntu/jammy/amdgpu-install_6.0.60002-1_all.deb)
sudo apt install ./amdgpu-install_6.0.60002-1_all.deb

# Update package lists
sudo apt update

# Install ROCm
sudo amdgpu-install --usecase=rocm
Enter fullscreen mode Exit fullscreen mode

Reboot your system after installation finishes.

Step 4: Add User to Groups
Grant access to hardware devices:

sudo usermod -a -G render,video $USER
Enter fullscreen mode Exit fullscreen mode

Log out and back in for group changes to register.

Step 5: Verify ROCm
Run verification commands:

rocminfo
hipinfo
Enter fullscreen mode Exit fullscreen mode

If these tools fail to detect your card, verify driver status via lsmod | grep amdgpu.

Step 6: Install PyTorch with ROCm
Visit the official PyTorch installation page to obtain the proper ROCm wheel URL. If you encounter issues where CUDA appears missing, refer to this walkthrough on fixing PyTorch CUDA not available on AMD GPUs.

pip install torch torchvision torchaudio --index-url [https://download.pytorch.org/whl/rocm6.0](https://download.pytorch.org/whl/rocm6.0)
Enter fullscreen mode Exit fullscreen mode

Step 7: Verify PyTorch GPU Detection
Test detection with Python:

import torch
print(torch.__version__)
print(torch.version.hip)
print(torch.cuda.is_available())
print(torch.cuda.device_count())
print(torch.cuda.get_device_name(0))
Enter fullscreen mode Exit fullscreen mode

If torch.cuda.is_available() returns False, consult this guide on how to fix GPU not detected in PyTorch for Windows and Linux.


Setting Up ComfyUI on AMD

Once PyTorch sees your GPU, ComfyUI installation proceeds smoothly.

Installation

Set up a isolated environment:

python -m venv comfyui-env
source comfyui-env/bin/activate
Enter fullscreen mode Exit fullscreen mode

Install PyTorch with ROCm, then clone ComfyUI:

git clone [https://github.com/comfyanonymous/ComfyUI.git](https://github.com/comfyanonymous/ComfyUI.git)
cd ComfyUI
pip install -r requirements.txt
python main.py
Enter fullscreen mode Exit fullscreen mode

Access the interface at http://localhost:8188.

Directory Structure

ComfyUI/
+-- main.py
+-- models/
|   +-- checkpoints/
|   +-- vae/
|   +-- loras/
|   +-- controlnet/
|   +-- upscale_models/
|   +-- clip/
+-- custom_nodes/
+-- output/
+-- workflows/
Enter fullscreen mode Exit fullscreen mode

Place model weights inside models/checkpoints/, VAEs in models/vae/, and custom extensions in custom_nodes/.


VRAM Optimization

VRAM management dictates what resolution and batch sizes you can generate on AMD GPUs.

How VRAM Is Consumed

  • Model weights: UNet, text encoder, and VAE weights occupy base memory. SD 1.5 FP16 models require ~3.5 GB, while SDXL FP16 models require ~6.5 GB.
  • Activations: Intermediate calculations generated during the pass. Higher resolutions produce larger tensors.
  • Sampler state: Step calculations held by KSampler.
  • Output buffers: Final images and latent structures.

Optimization Strategies

Optimization Memory Reduction Performance Impact When to Use AMD Considerations
Lower resolution High Quality trade-off Always start here Same as NVIDIA
Smaller batch High Slower total throughput Always start here Same as NVIDIA
Tiled VAE Moderate Slightly slower decode High-res workflows Built into ComfyUI
FP16 models Moderate Minimal Always use ROCm handles FP16 well
Smaller model High Quality trade-off Low VRAM SD 1.5 instead of SDXL
Disable custom nodes Variable Varies Troubleshooting Node compatibility varies
Attention optimization Moderate Minimal Automatic in ComfyUI Avoid --xformers

Fixing Black Images

Black images indicate that the VAE decoder output generated zeroed or unstable numerical values.

Diagnostic Sequence

  1. Confirm GPU Detection: Run PyTorch verification tests.
  2. Test Known-Good Checkpoint: Load standard SD 1.5 in a basic workflow.
  3. Disable Custom Nodes: Remove custom nodes that may alter execution pipelines.
  4. Test Different VAE: Switch between baked-in VAEs and external standard VAEs.
  5. Check Precision: Switch to FP32 for VAE decoding if numerical instability occurs in FP16.
  6. Check VRAM: Monitor usage via watch -n 1 rocm-smi to catch silent out-of-memory failures.
  7. Inspect Logs: Search terminal logs for HIP-specific warnings.

CUDA OOM Errors on an AMD System

When PyTorch encounters memory exhaustion under ROCm, it raises errors titled CUDA out of memory. This happens because ROCm uses PyTorch's CUDA-compatible API names.

For systemic memory management strategies across ML workflows, read this guide on fixing CUDA OOM on local LLMs and image models.

import torch
# If this returns a string version, you are on ROCm:
print(torch.version.hip)
Enter fullscreen mode Exit fullscreen mode

If torch.version.hip is active, a CUDA OOM error simply means your physical AMD VRAM is full. Reduce generation resolution or batch size to resolve it.


Performance: AMD vs NVIDIA

Factor NVIDIA AMD
Installation complexity Lower Higher on Linux, complex on Windows
PyTorch support Mature Improving steadily
Ecosystem compatibility High Variable for custom extensions
VRAM per dollar Lower Higher
Stability High Stable on Linux with tested builds

Real-World Project Examples

Scenario 1: SD 1.5 on Mid-Range Hardware

  • Hardware: Radeon RX 6700 XT (12 GB VRAM)
  • OS: Ubuntu 22.04 LTS with ROCm 6.0
  • Workflow: Standard 512x512 generation, batch size 1.
  • Result: Stable generation without special VRAM flags.

Scenario 2: SDXL on an 8 GB Card

  • Hardware: Radeon RX 7600 (8 GB VRAM)
  • OS: Ubuntu 22.04 LTS
  • Workflow: 1024x1024 SDXL execution using Tiled VAE and FP16 weights.
  • Result: Workable, though memory pressure remains high. Batch size must remain 1.

Scenario 3: Complex Workflows with LoRA & ControlNet

  • Hardware: Radeon RX 6800 XT (16 GB VRAM)
  • OS: Linux
  • Workflow: 768x768 generation loading one base checkpoint, two LoRAs, and a ControlNet depth preprocessor.
  • Result: Successfully runs due to 16 GB buffer, with peak VRAM utilization reaching ~13.5 GB.

Troubleshooting Decision Tree

[ Symptom: Generation Issue ]
       |
       +---> GPU Not Detected?
       |        |---> Run lspci (Check Hardware)
       |        |---> Run rocminfo (Check ROCm Driver)
       |        +---> Check user groups (render, video)
       |
       +---> Black Images Produced?
       |        |---> Test official SD 1.5 checkpoint
       |        |---> Set VAE precision to FP32
       |        +---> Disable custom nodes
       |
       +---> CUDA OOM Error?
                |---> Check torch.version.hip
                |---> Enable Tiled VAE
                +---> Lower image resolution / batch size
Enter fullscreen mode Exit fullscreen mode

Performance Optimization Checklist

  • Confirm amdgpu driver is active and kernel-compatible.
  • Confirm ROCm version matches installed PyTorch wheel.
  • Ensure PyTorch uses ROCm index, not standard CUDA Index.
  • Use FP16 format for checkpoints.
  • Keep initial generations at base model resolutions (512x512 for SD 1.5, 1024x1024 for SDXL).
  • Enable Tiled VAE during high-resolution decoding.
  • Avoid passing --xformers flags.
  • Track real-time memory using rocm-smi.

Frequently Asked Questions

Can Stable Diffusion run on AMD GPUs?

Yes. On Linux with ROCm, Stable Diffusion runs well on RDNA 2 and RDNA 3 cards. On Windows, WSL2 or DirectML provide operational paths.

Is ROCm required?

For practical performance on Linux, yes. DirectML exists on Windows but exhibits slower performance.

Is Linux better than Windows for AMD AI workloads?

Yes. The Linux ROCm stack is significantly more mature and performant.

How much VRAM is recommended?

8 GB handles SD 1.5 comfortably. 12 GB to 16 GB is recommended for SDXL and complex ControlNet pipelines.


Final Verdict

The AMD path for Stable Diffusion requires more initial setup than NVIDIA, but it is fully functional. If you own a Radeon RX 6000 or 7000 series GPU with 12 GB or more of VRAM, running ComfyUI on Linux yields great results without requiring new hardware purchases.

Top comments (0)