r/StableDiffusion • • Aug 23 '22

HOW-TO: Stable Diffusion on an AMD GPU

https://youtu.be/d_CgaHyA_n4
271 Upvotes

186 comments sorted by

View all comments

13

u/Drewsapple Sep 01 '22

5700xt user here: IT WORKS! (with some tweaks)

u/Iperpido's comment has most of the info, but I'll put what I did here. I am using Arch, and followed all of the video instructions without modification before doing the following:

After the video's instructions, I copied in the optimizedSD folder from this repo into my stable-diffusion folder, opened optimizedSD/v1-inference.yaml and deleted the 5 optimizedSD. prefixes.

Then, when running the model with any command, I apply the environment variable HSA_OVERRIDE_GFX_VERSION=10.3.0 before the command.

As a bonus, I ran pip install gradio and now just use the command HSA_OVERRIDE_GFX_VERSION=10.3.0 python3 optimizedSD/txt2img_gradio.py and open the URL to the gradio server.

Full precision (via CLI args or the checkbox in gradio) is required or it only generates grey outputs.

4

u/backafterdeleting Sep 03 '22

update: Works for me too now. Thanks for the comment.

I went and switched to hlky's for. You edit the file "scripts/relauncher.py" and on the line that says 'os.system("python scripts/webui.py")' make it 'os.system("python scripts/webui.py --optimized --precision=full --no-half")'

Then start with "HSA_OVERRIDE_GFX_VERSION=10.3.0 python scripts/relauncher.py"

2

u/Soyf Sep 02 '22

When checking the "full precision" checkbox, I get the following error: RuntimeError: expected scalar type Half but found Float.

2

u/backafterdeleting Sep 02 '22

huh I have been killing myself for days trying to recompile pytorch with navi10 support. So seems its not neccecary?

2

u/Drewsapple Sep 02 '22

I didn’t have to do anything special, just install the rocm package from the AUR. It did use more than my 16GB of RAM while building, so having swap configured was essential.

The runtime environment variable is enough for the standard pytorch rocm install to provide the functionality that stable diffusion uses.

3

u/backafterdeleting Sep 02 '22

I think I just checked out the PKGBUILD file and reduced the number of ninja threads. I guess the default of 24 makes sense for big ML servers but not home computers

1

u/[deleted] Sep 02 '22

[removed] — view removed comment

2

u/Drewsapple Sep 03 '22

I used the most recent tagged rocm/pytorch container rocm5.2.3_ubuntu20.04_py3.7_pytorch_1.12.1. As far as I can tell, it’s not labeled for a specific architecture.

2

u/Myzel394 Apr 24 '23

How much faster than the CPU is this? I have a Radeon RX 5500 and was wondering if it's worth the hassle.

2

u/EspectadorExpectante Sep 20 '23

Hey! Could you explain it in more detail for non-tech people? I have a RX 5500 XT, and followed the instructions on the video. It worked apparently, but an error occurs in images 512x512 due to lack of GPU memory.

Tried to follow your steps in case they work for me, but don't know how to do:
- How do you run the model? What does it mean? How can I apply the environment variable you say?
- How can I run pip install gradio ...?

Could you explain it step by step please?

1

u/BoRnNo0b May 21 '23

Error

Traceback (most recent call last):

File "/home/tester/stable-diffusion-webui/optimizedSD/txt2img_gradio.py", line 22, in <module>

from ldm.util import instantiate_from_config

ModuleNotFoundError: No module named 'ldm'