HatefulSable's Guide to Installing Stable Diffusion WebUI on Ubuntu With an AMD GFX8 GPU
Last updated October 25, 2023.
Important
This guide is written for GFX8 (gfx803) GPUs only, such as the Radeon RX 580 and certain other Polaris-based graphics cards from the same generation. Do not follow this guide if your GPU is based on any other architecture.
This document is a start-to-finish guide to setting up Stable Diffusion WebUI on Ubuntu using a ROCm capable AMD GFX8 graphics card. The procedure has been tested on a system with the following specifications:
- Ubuntu 20.04.5 LTS
- Sapphire PULSE Radeon RX 580
- 16GB 2133MT/s RAM
If you have a setup similar to this one, this guide should contain all the information you need to get started with WebUI.
For Nvidia graphics cards, see https://rentry.org/sable-sdw-ubuntu-nvidia instead.
Warning!
This procedure involves installing software from many different sources, and possibly altering video drivers and other critical software on your computer. It is strongly recommended that you perform this installation on its own dedicated hard drive, separate from the operating system you use every day.
Before You Begin
Ensure that you know the difference between system RAM and VRAM. This guide refers to both at various times.
Check that you have a 64-bit CPU. Most computers from the past decade probably meet this requirement, but you may wish to verify this before continuing.
Check that you have a ROCm capable GFX8 GPU. If you are unsure about this, rocminfo
(installed later in this guide) can be used to confirm your GPU's architecture and compatibility. For more information, see https://community.amd.com/t5/knowledge-base/amd-rocm-hardware-and-software-support-document/ta-p/489937.
Install Ubuntu 20.04.5 LTS, available at https://releases.ubuntu.com/20.04.5/ubuntu-20.04.5-desktop-amd64.iso. You may choose a minimal installation, since only a web browser and basic utilities are required. This guide assumes that you are starting from a fresh installation and have not made any major changes to the operating system or software.
The PyTorch binaries used in this guide are available for Python 3.8 only. This procedure likely also works on Ubuntu 22.04 LTS (Jammy), but since that release comes with Python 3.10, you would need to install Python 3.8 and use it instead of the default Python 3. For the sake of simplicity, this guide calls for Ubuntu 20.04 LTS (Focal) only.
Install ROCm
Install amdgpu-dkms
from the AMDGPU 5.4.2 repository.
Reboot the system. You must install the ROCm software stack from the ROCm 5.2 repository, since this is the version that PyTorch will be expecting.
Reboot the system. You can now run rocminfo
and clinfo
to verify that ROCm was installed.
Review the output of rocminfo
to ensure that your GPU is based on the GFX8 architecture. Under the GPU's agent information, it should show "gfx803" as the agent name.
The output of clinfo
may report that there are no OpenCL devices available. This is to be expected.
Install Stable Diffusion WebUI
Move your CKPT or SafeTensors files to the models/Stable-diffusion
folder. Be sure to give your models meaningful filenames. You can find download links for various models at https://rentry.org/sdmodels.
Open webui-user.sh
and edit it as needed. You must uncomment and set COMMANDLINE_ARGS
to include --disable-safe-unpickle
since PyTorch 1.11 does not support that feature. Additionally, you may need to add --medvram --opt-split-attention
if your GPU does not have much VRAM. See the comments in the file for more information.
Warning!
Your system can be compromised by malicious CKPT files. Use this software at your own peril.
When you are ready to continue, if you have changed your terminal's current working directory, change it back to the WebUI folder.
Install PyTorch
Official builds of PyTorch no longer support GFX8, so you must install binaries specially compiled for this architecture.
Configure Swap File
Warning!
Using a swap file on a system with a solid-state drive can cause the SSD to fail prematurely, potentially resulting in data loss.
For systems with 16GB system RAM or more:
You should disable the swap file to increase performance and avoid unnecessary wear on your storage device.
For systems with less than 16GB system RAM:
Do not disable the swap file. However, you should consider adding more RAM to your system if you plan to use WebUI frequently.
WebUI may crash with a simple Killed
error message while launching, usually when loading model weights. This may be caused by the program running out of both memory and swap space. You can allocate a larger swap file to see if this resolves the issue.
Run free -h
to confirm that the swap file has been set up as expected.
Launch Stable Diffusion WebUI
Skip the following step this time, but in the future, after you have restarted your terminal application or rebooted the system, remember to change to the WebUI folder and activate the virtual environment before launching WebUI.
Finally, launch the program.
Launching the program for the first time may take quite a while. Eventually, you should see a URL such as http://127.0.0.1:7860
, which you can open in Firefox to access WebUI's web interface.
Happy prompting!
Change Log
2023-10-25
- Remove unneeded system specifications.
- Remove comment about
model.ckpt
filename, since that has been irrelevant for a long time. - Rewrite section regarding the swap file.
- Refer to the program as WebUI instead of SDW.