stable-diffusion-webui
stable-diffusion-webui copied to clipboard
RX 570 No usage by the AI, CPU does the lifting
When I try to use the ai, i get it all launched in web, but it only uses my cpu. I followed the instructions to install it on linux here but still didnt work.
OS: Ubuntu 22.04.1 LTS
Same here.
Device: AMD Radeon RX 570 Series (polaris10, LLVM 12.0.1, DRM 3.46, 5.18.19_1) (0x67df) Distro: Void Linux x86_64
I had to manually add --skip-torch-cuda-test into COMMANDLINE_ARGS in launch.sh to get this far. It seems Torch can't see/use the GPU.
No warnings about MIopen. Is it a pre-req I have to install anyway?
Cloning Stable Diffusion into repositories/stable-diffusion...
Cloning Taming Transformers into repositories/taming-transformers...
Cloning CodeFormer into repositories/CodeFormer...
Cloning BLIP into repositories/BLIP...
Cloning LDSR into repositories/latent-diffusion...
Installing requirements for CodeFormer
Installing requirements for Web UI
Launching Web UI with arguments: --precision full --no-half
Warning: caught exception 'No HIP GPUs are available', memory monitor disabled
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [7460a6fa] from /home/valentine/scratch/stable-diffusion-webui/models/model.ckpt
Global Step: 470000
Model loaded.
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
txt2img: Red car with a camera on top
60%|█████████████████████████████████████████████████████████████████████████▏ | 12/20 [04:27<02:58, 22.37s/it]
EDIT:
[W NNPACK.cpp:51] Could not initialize NNPACK! Reason: Unsupported hardware.
The software definitely worked -- I have an output image -- but according to radeontop and top it's using my CPU not my GPU.
Not sure, but AMD graphic cards might not be supported
AMD GPUs are not supported out of the box. Check out the wiki on how to use them here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs
yeah you see that's the problem, i did all that except docker but still aint working. newer gfx1030 gpus are supported as it seems but im trying to find a way to make gfx803 work on it aswell
Same issue here, GPU isn't used. Followed the guide (https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs) on my Ubuntu 20.04.1 LTS, graphics card: AMD RX 5700 XT. Also added --skip-torch-cuda-test into COMMANDLINE_ARGS to get it going.
Now i always get this message when starting: /_home/djiff/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/cuda/init.py:83: UserWarning: HIP initialization: Unexpected error from hipGetDeviceCount(). Did you run some cuda functions before calling NumHipDevices() that might have already set an error? Error 101: hipErrorInvalidDevice (Triggered internally at ../c10/hip/HIPFunctions.cpp:110.) return torch._C.cuda_getDeviceCount() > 0
Dont know if its related to the issue though since i'm a basic noob.
Try adding HSA_OVERRIDE_GFX_VERSION=10.3.0 in launch command. Work on RX 5700 when launching with
TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' HSA_OVERRIDE_GFX_VERSION=10.3.0 python launch.py --precision full --no-half --medvram
export HSA_OVERRIDE_GFX_VERSION=10.3.0
also works
Try adding HSA_OVERRIDE_GFX_VERSION=10.3.0 in launch command. Work on RX 5700
Does not seem to have effect, still using CPU rather than GPU. Messages about 'No HIP GPUs are available' and 'Could not initialize NNPACK! Reason: Unsupported hardware' are still printed too.
$ source venv/bin/activate
(venv) $ export HSA_OVERRIDE_GFX_VERSION=10.3.0
(venv) $ TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' HSA_OVERRIDE_GFX_VERSION=10.3.0 python3 launch.py --precision full --no-half --medvram
Python 3.10.7 (main, Sep 7 2022, 15:23:13) [GCC 10.2.1 20201203]
Commit hash: 2ab64ec81a270c516816b5035860361ee145b9db
Installing requirements for Web UI
Launching Web UI with arguments: --precision full --no-half --medvram
Warning: caught exception 'No HIP GPUs are available', memory monitor disabled
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [7460a6fa] from /home/valentine/scratch/stable-diffusion-webui/models/model.ckpt
Global Step: 470000
Model loaded.
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
txt2img: testing 123
0%| | 0/20 [00:00<?, ?it/s][W NNPACK.cpp:51] Could not initialize NNPACK! Reason: Unsupported hardware.
Not sure, but AMD graphic cards might not be supported
AMD GPUs are not supported out of the box. Check out the wiki on how to use them here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs
plosee and mrdoep have directly linked to those instructions in their posts above. I'm also following them.
Possibly related to #783
@Veyrdite Have you tried deleting venv
dir and reinstalling with HSA_OVERRIDE_GFX_VERSION=10.3.0
? Also, running it inside docker might solve the issue with No HIP GPUs are available. I managed to get it working natively but had to wait for long time every time after relaunch so I went with docker. It works flawlessly, though I used rocm/pytorch:rocm5.2_ubuntu20.04_py3.7_pytorch_1.11.0_navi21
image. The one from the guide works too.
@Veyrdite Have you tried deleting
venv
dir and reinstalling withHSA_OVERRIDE_GFX_VERSION=10.3.0
? Also, running it inside docker might solve the issue with No HIP GPUs are available. I managed to get it working natively but had to wait for long time every time after relaunch so I went with docker. It works flawlessly, though I usedrocm/pytorch:rocm5.2_ubuntu20.04_py3.7_pytorch_1.11.0_navi21
image. The one from the guide works too.
Tried the reinstalling with HSA... issue remains. Didnt try Docker yet.
But tried to follow https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/1122#issuecomment-1261334452 but also get an error in the last step for amdgpu-install:
_rocm-opencl-runtime is already the newest version (5.2.0.50200-65). Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:
The following packages have unmet dependencies: rocm-hip-runtime : Depends: rocminfo (= 1.0.0.50200-65) but 5.0.0-1 is to be installed E: Unable to correct problems, you have held broken packages._
:(
But tried to follow #1122 (comment) but also get an error in the last step for amdgpu-install
That seems like a very convoluted way of solving a problem that has simpler solution. Unless there are some serious limitations in your system that don't allow you run docker or you need rocm for something else. Otherwise use docker and avoid dependency hell. You might want to create a user in a container before installing sd and running it as that user to avoid your outputs being owned by root.
@Veyrdite Have you tried deleting
venv
dir and reinstalling withHSA_OVERRIDE_GFX_VERSION=10.3.0
? Also, running it inside docker might solve the issue with No HIP GPUs are available. I managed to get it working natively but had to wait for long time every time after relaunch so I went with docker. It works flawlessly, though I usedrocm/pytorch:rocm5.2_ubuntu20.04_py3.7_pytorch_1.11.0_navi21
image. The one from the guide works too.Tried the reinstalling with HSA... issue remains. Didnt try Docker yet.
Ditto, just did a reinstall with export HSA_OVERRIDE_GFX_VERSION=10.3.0 and symlinked the 4GB model file. No change in behaviours.
I'll have to try the docker route.
Is there a chance I need to install more on my host system? The docs for this project don't mention me needing to install any ROCm stuff myself.
Is there a chance I need to install more on my host system?
It works without any ROCm packets on my system. I assume it should work on yours as well since the docker image has all the required stuff.
The following packages have unmet dependencies: rocm-hip-runtime : Depends: rocminfo (= 1.0.0.50200-65) but 5.0.0-1 is to be installed E: Unable to correct problems, you have held broken packages._
Which version of rocminfo is installed? Maybe try deleting it so the installer can try to fetch it on its own. Or go for this one and make sure only version 5.0 dependencies are present in your system: https://ubuntu.pkgs.org/22.04/ubuntu-universe-amd64/rocminfo_5.0.0-1_amd64.deb.html
But tried to follow #1122 (comment) but also get an error in the last step for amdgpu-install
That seems like a very convoluted way of solving a problem that has simpler solution. Unless there are some serious limitations in your system that don't allow you run docker or you need rocm for something else. Otherwise use docker and avoid dependency hell. You might want to create a user in a container before installing sd and running it as that user to avoid your outputs being owned by root.
I tried the Docker route now. Didn't create a user in a container before installing though. Tried to install inside the container according to the AMD/Docker guide and have the same error forcing me to add --skip-torch-cuda-test into COMMANDLINE_ARGS. I'll stop right here since i'm anyway running out of space on my partition again (this Docker solution seems to be much more disk space demanding..). I'll clean the partition on regroup myself.. :\
I've just tried the docker route as per the docker instructions on the AMD wiki page. It still required me to use COMMANDLINE_ARGS='--skip-torch-cuda-test', still emitts the same error messages and still runs completely in the CPU.
(Yes I double checked that I didn't still have to old instance running. Only running the webui in the new docker install and that's where I'm seeing a progress bar in a terminal)
(venv) root@x:/dockerx/stable-diffusion-webui/models# COMMANDLINE_ARGS='--skip-torch-cuda-test' TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' REQS_FILE='requirements.txt' python launch.py --precision full --no-half
python: can't open file 'launch.py': [Errno 2] No such file or directory
(venv) root@x:/dockerx/stable-diffusion-webui/models# cd ..
(venv) root@x:/dockerx/stable-diffusion-webui# COMMANDLINE_ARGS='--skip-torch-cuda-test' TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' REQS_FILE='requirements.txt' python launch.py --precision full --no-half
Python 3.7.13 (default, Mar 29 2022, 02:18:16)
[GCC 7.5.0]
Commit hash: be5555fce4612fdfb4a06e831e3f1a8d055fdf9a
Installing requirements for Web UI
Launching Web UI with arguments: --precision full --no-half
Warning: caught exception 'No HIP GPUs are available', memory monitor disabled
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [7460a6fa] from /dockerx/stable-diffusion-webui/models/model.ckpt
Global Step: 470000
Model loaded.
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
txt2img: test
100%|██████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [07:45<00:00, 23.29s/it]
[W NNPACK.cpp:51] Could not initialize NNPACK! Reason: Unsupported hardware.███████████████████████████| 20/20 [07:22<00:00, 22.71s/it]
Total progress: 100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [07:42<00:00, 23.12s/it]
The following packages have unmet dependencies: rocm-hip-runtime : Depends: rocminfo (= 1.0.0.50200-65) but 5.0.0-1 is to be installed E: Unable to correct problems, you have held broken packages._
Which version of rocminfo is installed? Maybe try deleting it so the installer can try to fetch it on its own. Or go for this one and make sure only version 5.0 dependencies are present in your system: https://ubuntu.pkgs.org/22.04/ubuntu-universe-amd64/rocminfo_5.0.0-1_amd64.deb.html
I actually followed the description this time more properly (apparently last time i forgot to install libstd++-10-dev). Looks like amdgpu installation now worked properly
Is there a chance I need to install more on my host system?
It works without any ROCm packets on my system. I assume it should work on yours as well since the docker image has all the required stuff.
Thankyou, good to know. I don't have anything ROCm related available in my package manager.
EDIT: Other stable diffusion related projects seem to recommend I compile (or install pre-compiled) ROCm kernel modules. I'm not sure how this project is working around that, perhaps it's an undocumented requirement?
Possible reason at https://old.reddit.com/r/StableDiffusion/comments/x37wwb/i_think_its_impossible_to_run_sd_on_an_rx_570_and/
The RX 570/580/590 are in the GFX8 series. Support for GFX8 was dropped in ROCm 4.0.
EDIT possible workaround at https://old.reddit.com/r/StableDiffusion/comments/ww436j/howto_stable_diffusion_on_an_amd_gpu/ipkfm35/?context=3
I can confirm StableDiffusion works on 8GB model of RX570 (Polaris10, gfx803) card. No ad-hoc tuning was needed except for using FP16 model.
I built my environment on AMD ROCm docker image (rocm/pytorch), with custom environment variable passed with
docker ... -e ROC_ENABLE_PRE_VEGA=1
.While above docker image provides working ROCm setup, bundled PyTorch does not have gfx803 support enabled. You have to rebuild it with gfx803 support (re-)enabled. I'm still struggling with my build, but found pre-built packages at https://github.com/xuhuisheng/rocm-gfx803 . Since AMD docker provides Python-3.7 and pre-build wheel packages are targeted for Python-3.8, you will have to reinstall Python as well.
The ROC_ENABLE_PRE_VEGA flag seems to have some discussions at https://github.com/RadeonOpenCompute/ROCm/issues/1659
It still required me to use COMMANDLINE_ARGS='--skip-torch-cuda-test'
Try launching/reinstalling with TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' HSA_OVERRIDE_GFX_VERSION=10.3.0 python launch.py --precision full --no-half --medvram
. It no longer requires passing REQS_FILE='requirements.txt'
, in fact it broke my installation after yesterdays k-diffusion update offering to use --skip-torch-cuda-test
which did nothing, but recreating venv helped. Maybe update python as per guide. Try ROC_ENABLE_PRE_VEGA=1
instead of or together with HSA_OVERRIDE_GFX_VERSION=10.3.0
.
I've just tried a fresh native (non-docker) install with export ROC_ENABLE_PRE_VEGA=1, no dice. I'll try your REQS_FILE changes tomorrow.
I successfully installed the GPU drivers now following https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/1122#issuecomment-1261334452. Last time i forgot to install libstd++-10-dev (hint for this is found in the dummy packages links..) which seems to be crucial for the amdgpu install (amdgpu-install -y --usecase=graphics) to work. IT WORKS NOW, i can generate basic pictures with my RX 5700 XT in about 8s (compared to ~200s before). Be aware that as several people mentioned here, first image generation is still slow but after that its fine. Hope it helps.
Addition: seems like i also need to run TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' HSA_OVERRIDE_GFX_VERSION=10.3.0 python launch.py --precision full --no-half --medvram
to make it work
@mrdoerp That guide specifies the "amdgpu-pro" (proprietary) drivers instead of "amdgpu" (open source).
Does that mean the proprietary AMD drivers are a requirement of this project if you use an AMD card?
Both have OpenCL support as far as I can tell. The differences are a bit confusing :|
@mrdoerp That guide specifies the "amdgpu-pro" (proprietary) drivers instead of "amdgpu" (open source).
Does that mean the proprietary AMD drivers are a requirement of this project if you use an AMD card?
Both have OpenCL support as far as I can tell. The differences are a bit confusing :|
Bro, i have no clue about anything. All i know is i followed the guide and 49RpK5dY Torch command and after that it worked :)
Hi,
it seems that the AMD repository for Ubuntu is kinda broken at the moment. You have to add the PPA repo by oibaf, set the group permission for "video" and then run the official installer to get things working.
sudo amdgpu-install --usecase=rocm
According to AMD this will install:
- OpenCL (ROCr/KFD based) runtime
- HIP runtimes
- Machine learning framework
- All ROCm libraries and applications
- ROCm Compiler and device libraries
- ROCr runtime and thunk
I am not sure if this project will also run with only
--usecase=hip
or
--usecase=hiplibsdk
as well.
Depending on your specific setup you might also have to meet some further prerequisites as described in #1122 and add the dummy packages to skip errors related to "libstdc" and "libgcc".
Again, Ubuntu is problematic at the moment since the installer cannot contact the AMD repo correctly. I did another run with openSUSE the other day and the AMD guide worked just right out of the box. Furthermore, in a second run, I was also able to download and install the Torch and ROCm dependencies even without pre-installing amdgpu. If you are encountering issues you cannot fix, you should try another distro which is not Ubuntu/Debian-based.
Try adding HSA_OVERRIDE_GFX_VERSION=10.3.0 in launch command. Work on RX 5700 when launching with
TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' HSA_OVERRIDE_GFX_VERSION=10.3.0 python launch.py --precision full --no-half --medvram
export HSA_OVERRIDE_GFX_VERSION=10.3.0
also works
Gets past the original issue on my RX 570 8GB, but segfaults:
(venv) ➜ stable-diffusion-webui git:(master) ✗ TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.2.3' HSA_OVERRIDE_GFX_VERSION=10.3.0 python launch.py --precision full --no-half --medvram
Python 3.10.7 (main, Sep 7 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-1)]
Commit hash: 5da1ba0e91a81804dc911d34c9a2e6956a23199c
Installing requirements for Web UI
Launching Web UI with arguments: --precision full --no-half --medvram
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [7460a6fa] from /home/******/stable-diffusion-webui/models/Stable-diffusion/sd-v1-4.ckpt
Global Step: 470000
[1] 112804 segmentation fault (core dumped) TORCH_COMMAND= HSA_OVERRIDE_GFX_VERSION=10.3.0 python launch.py --precision
@capitalistspz Try deleting and recreating venv up until
python -m pip install --upgrade pip wheel
and after that launching it with a script
#!/bin/bash
cd $HOME/stable-diffusion-webui
source venv/bin/activate
export HSA_OVERRIDE_GFX_VERSION=10.3.0
TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' python launch.py --precision full --no-half --medvram
If that doesn't work you should consider trying docker. It will probably work out the box with TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' HSA_OVERRIDE_GFX_VERSION=10.3.0 python launch.py --precision full --no-half --medvram
You may have to use ROCM_ENABLE_PRE_VEGA=1
instead of HSA_OVERRIDE_GFX_VERSION=10.3.0
I tried the docker container, it segfaults in the same place. I tried native again with ROCM_ENABLE_PRE_VEGA=1
without HSA_OVERRIDE_GFX_VERSION
, and get this error about not being able to use the GPU
RuntimeError: Error running command.
Command: "/home/******/stable-diffusion-webui/venv/bin/python" -c "import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'"
Error code: -6
stdout: <empty>
stderr: "hipErrorNoBinaryForGpu: Unable to find code object for all current devices!"
If I use both environment variables, it segfaults in the same place as the original attempt.
If I change the ROCM version to 5.2.3, no matter what combination of those environment variables, it gets the error above about being unable to use the GPU.
Note: I get no error on 5.2.3 if I do --skip-torch-cuda-test
, but also don't get any GPU Usage
Something to consider...
You have to restart after installing some of these things (ROCM / Amdgpu-pro / libcc dummy package)
Not sure which but you might have been in a state that would have 'worked' and then tested it without restarting so the test shows a failure.
@capitalistspz you're missing an essential piece of information.
Command: "/home/******/stable-diffusion-webui/venv/bin/python" -c "import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'"
Add the commandline parameter like it says.
If your AMD GPU is installed and working correctly for 'Cuda' / Pytorch operations, it will STILL pick up like that. There is a discussion on a AMD repo somewhere about it.
This is by design, so that you can detect wether a GPU is AMD/Nvidia or something like that. So you have to add that parameter to skip the check
and then when torch.load('cuda') happens, it (if installed correctly) uses your GPU as if it is CUDA, even though it's not.
ROCM wrapper handles that.
~~I am successfully up and running!~~ (EDIT: no I'm not, it is only running on my CPU, but the following may still be useful information) I am on Alpine Linux edge, with an RX 570 4GB and a Pentium G4560 with 8GB of RAM.
I did not need ROC_ENABLE_PRE_VEGA
or HSA_OVERRIDE_GFX_VERSION
. But I did need the nightly pytorch, otherwise I would almost immediately get an "Illegal instruction" error on startup.
Once in the stable-diffusion-webui directory within the container, I run these commands:
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip wheel
export COMMANDLINE_ARGS=--skip-torch-cuda-test
export TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/nightly/rocm5.2'
export REQS_FILE='requirements.txt
python launch.py --medvram --opt-split-attention --precision=full --no-half
Side note: I see ROC_ENABLE_PRE_VEGA
sometimes being spelled as ROCM_ENABLE_PRE_VEGA
in this thread.
To get everything to fit within 8GB of RAM on my host system, I set up 4GB of zram swap (zstd compression) and 4GB of regular swap (low priority).
I also had to recompile the kernel with the CONFIG_HSA_AMD option (Gentoo wiki ROCm article), otherwise I would get an error about not having a /dev/kfd
. It appears other distros have this on by default, ~~so I'll open an issue with Alpine to see if it can be enabled by default here too~~ (EDIT: it is now enabled in 6.0.2). I don't have any ROCm userspace components on my host system.
I successfully installed the GPU drivers now following #1122 (comment). Last time i forgot to install libstd++-10-dev (hint for this is found in the dummy packages links..) which seems to be crucial for the amdgpu install (amdgpu-install -y --usecase=graphics) to work. IT WORKS NOW, i can generate basic pictures with my RX 5700 XT in about 8s (compared to ~200s before). Be aware that as several people mentioned here, first image generation is still slow but after that its fine. Hope it helps.
Addition: seems like i also need to run
TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.1.1' HSA_OVERRIDE_GFX_VERSION=10.3.0 python launch.py --precision full --no-half --medvram
to make it work
Hi. Can you make a vhdx image of your Ubuntu with a working stable diffusion? I have already tried many times to do everything according to the instructions, but have not been successful. Maybe I can use your image? My rx5700 graphics card uses the same drivers. In theory it should work.