santa hat
deerdeer nosedeer glow
Sign In

Running Automatic1111 on Ubuntu for AMD gpus

2

Introduction

This guide focus on installing Auto1111 for AMD users with maximum performance in mind.

Sadly, no decent solution in term of speed and VRAM usage is currently available on Windows, Linux is needed for a decent experience.

Feedback:

This guide was tested on my personal desktop computer equipped with a RX6800XT and 32Go of ram. All images posted on my Civitai account (mostly nsfw) were generated using this solution and gpu.

Speed Results:

About 7.20it/s for 512x512

Disclaimer: Minimal knowledge of Linux is mandatory, I don't recommend using this if you never installed a Linux distribution before.

Install Ubuntu 22.04.02 LTS from a USB Key

  • Perform a standard dual boot install. (no third party proprietary repositories)

Update Ubuntu

sudo apt-get update
sudo apt-get dist-upgrade

Reboot.

Install AMD drivers and ROCm

Needed Prerequisites for ROCm:
https://rocm.docs.amd.com/en/latest/deploy/linux/prerequisites.html

sudo apt-get install gnupg2 gawk curl git
sudo usermod -a -G render $LOGNAME
sudo usermod -a -G video $LOGNAME

Install AMD drivers:

Download amdgpu-install_5.6.50600-1_all.deb and install it:
https://rocm.docs.amd.com/en/latest/deploy/linux/installer/install.html

sudo apt update
wget https://repo.radeon.com/amdgpu-install/5.6/ubuntu/jammy/amdgpu-install_5.6.50600-1_all.deb
sudo apt install ./amdgpu-install_5.6.50600-1_all.deb

Install ROCm:

sudo amdgpu-install --rocmrelease=5.6.0 --usecase=rocm,rocmdev,rocmdevtools,lrt,hip,hiplibsdk,mllib,mlsdk --vulkan=pro --no-32 --accept-eula

Reboot.

Check your ROCm info, your AMD gpu should be listed:

rocminfo

Install Auto1111

sudo apt-get install git
sudo apt install python3.10-venv
sudo apt-get install libstdc++-12-dev

Edit the ~/.bashrc file:


Add alias python=python3 at the end of your .bashrc file, save and close.

source ~/.bashrc
cd ~
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip wheel
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm5.5

At the time beeing, pytorch for ROCm5.6 is not available, but the 5.5 version should be ok.

Running Auto1111

cd stable-diffusion-webui
source venv/bin/activate
python launch.py --precision full --no-half --medvram

Running on low VRAM

cd stable-diffusion-webui
source venv/bin/activate
PYTORCH_HIP_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 python launch.py --precision full --no-half

Running on RDNA2 & RDNA3 Series

cd stable-diffusion-webui
source venv/bin/activate
python launch.py

--precision full & --no-half are not needed on RDNA2 or RDNA3, and will save a lot of VRAM.
If you don't generate big images, you can also skip the -medvram.

Please note, first time generating an image could take some time as a cache is built.

2