ComfyUI with Stable Diffusion on AMD GPUs
Hi folks,
I was browsing Reddit when I came across a comment by ricperry1 that
explained how to use ComfyUI on Ubuntu 24.04 using the system-provided
ROCm packages [1]. The original motivation seems to have been to use
StableDiffision on his AMD GPU in the window of time between the release
of Ubuntu 24.04 and the release of ROCm 6.2 (which is when AMD began
providing packages for Ubuntu 24.04).
I didn't realize what ricperry1 achieved was possible! I guess the
PyTorch packages must dlopen the ROCm libraries that they depend on, and
are therefore somewhat flexible about what versions are used.
I've tweaked ricperry1's guide slightly and included the commands below.
This is probably not a minimal set of packages required, but these are
working instructions for building and using StableDiffusion with AMD
GPUs using only Debian Trixie system packages for ROCm and pip packages
for the AI libraries:
sudo apt-get -y install git wget python3 python3-venv python3-pip synaptic \
hipcc libhiprtc-builtins5 librccl1 librocalution0 librocblas0
librocfft0 \
librocsolver0 librocsparse0 rocm-smi rocminfo libhiprand1 radeontop
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
git checkout 3cacd3fca54dc8928ae27dcff6c89f1d40c34038
python3 -m venv venv3
source venv3/bin/activate
pip3 install torch torchvision torchaudio --index-url
https://download.pytorch.org/whl/rocm6.2
pip install -r requirements.txt
wget -c -O ./models/checkpoints/v1-5-pruned-emaonly.ckpt \
https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt
python3 main.py
After running the above commands, you should be able to open your
browser to the URL that was printed in the console and click "Queue" to
generate an image.
The PyTorch binaries contain GPU code, so even though the Debian ROCm
libraries have been extended to additional GPU architectures, this
method is probably limited to architectures with official support from
AMD (though some other architectures may be usable with the HSA override
environment variable [2]). I only tested on my Radeon VII, but I'd
expect it to work on Vega, CDNA 1, CDNA 2, Navi 21, Navi 31, and Navi 32
GPUs by default.
The performance is probably not ideal, especially on CDNA 2 or RDNA 3
GPUs, but this is nevertheless a big step forward in my perception of
the usability of the ROCm system packages on Debian and Ubuntu.
Sincerely,
Cory Bloor
[1]:
https://www.reddit.com/r/comfyui/comments/1d8d1k6/rocm_ubuntu_2404_basic_comfyui_setup_instructions/
[2]:
https://salsa.debian.org/rocm-team/community/team-project/-/wikis/Supported-GPU-list#architecture-notes
Reply to: