Hi all,
I finally had some time to write down my adventures of getting ROCm to work on my machine. I got it working a couple of months ago, but now an update borked something and I had to redo most steps, so I finally have a good step by step guide for any distro (hopefully).
If you don’t already know what ROCm is, why are you even reading this?
If you want to learn more, read this first
https://rocm.docs.amd.com/en/latest/rocm.html
Now, let’s get started with the guide.
The first step to the magic is to install Distrobox and Podman
sudo zypper in distrobox podman
Not sure if this is necessary, but it shouldn’t hurt.
Add yourself to the render and video group like so
sudo groupadd render
sudo groupadd video
sudo usermod -aG render,video $LOGNAME
After that you have to create an Ubuntu 22.04 distrobox and name it rocm
distrobox create -i ubuntu:22.04 -n rocm
distrobox enter rocm
sudo apt update
sudo apt upgrade
sudo apt install build-essential
Now install ROCm, but first change your direction to your Downloads folder.
Otherwise you will always wonder why you have a .deb file in your home folder
cd ~/Downloads
https://rocm.docs.amd.com/en/latest/deploy/linux/installer/install.html
Strangely the newest version (5.7.1) doesn’t work with Blender (4.0.1), so I write the instructions for ROCm version 5.6.1 (which I confirmed working while testing). Also you don’t need the pro driver, don’t listen to their LIES
sudo apt update
wget https://repo.radeon.com/amdgpu-install/5.6.1/ubuntu/jammy/amdgpu-install_5.6.50601-1_all.deb
sudo apt install ./amdgpu-install_5.6.50601-1_all.deb
amdgpu-install --usecase=rocm --no-dkms
Now you should have a working ROCm installation and can always access it by entering the distrobox. If you have a CPU with graphic capability (Intel / AMD Ryzen 7000 series), you should disable the integrated graphics in your BIOS. Otherwise the ROCm stack will get confused and choose your CPU as your primary agent.
To get back into the distrobox, type
distrobox enter rocm
To test if ROCm is working, you can use these cli tools
rocminfo
rocm-smi
clinfo
Now to the applications.
Blender
For Blender, I also had to install two more libraries
sudo apt install libxkbcommon0 libsm6
Then you should be good to go. In this guide I will use the Steam version of Blender
~/.local/share/Steam/steamapps/common/Blender/blender
Go to Edit > Preferences > System > HIP
and select your GPU if it isn’t already.
Then go into the scene properties on the right and select Cycles as your Render Engine and GPU Compute as your Device. If Blender freezes you have to hard restart your PC and install a different version of ROCm.
Now if you want to, you can create a .desktop file in ~/.local/share/applications/
and name it blender.desktop
Open it with a text editor (Kate) and replace everything with
[Desktop Entry]
Categories=Distrobox;System;Utility
Comment[en_US]=via Ubuntu ROCm distrobox
Comment=via Ubuntu ROCm distrobox
Exec=/usr/bin/distrobox enter rocm -- ./blender
GenericName[en_US]=Start Blender from Steam
GenericName=Start Blender from Steam
Icon=blender
Keywords=distrobox;
MimeType=
Name[en_US]=Blender
Name=Blender
NoDisplay=false
Path=~/.local/share/Steam/steamapps/common/Blender/
StartupNotify=true
Terminal=true
TerminalOptions=
TryExec=/usr/bin/distrobox
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=
Change the Path, if you installed Blender differently.
Stable Diffusion
Optional library for better performance
sudo apt install libtcmalloc-minimal4
https://ubuntu.pkgs.org/22.04/ubuntu-main-amd64/libtcmalloc-minimal4_2.9.1-0ubuntu3_amd64.deb.html
Now we will install the Stable Diffusion web UI by Automatic1111
GitHub - AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UI
You can try to install a different web UI, but this is the only one I got working while testing.
First, install the dependencies
sudo apt install wget git python3 python3-venv libgl1 libglib2.0-0
Then clone the repo to your favorite folder. For me it’s
cd ~/Documents/Git
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui && cd stable-diffusion-webui
Open the file webui-user.sh
and add this to the end. Uncomment appropriately
#git pull #update the web UI on every start
#export HSA_OVERRIDE_GFX_VERSION=11.0.0 #7000 series GPU
#export HSA_OVERRIDE_GFX_VERSION=10.3.0 #6000 series GPU
export COMMANDLINE_ARGS="--medvram --upcast-sampling --opt-sub-quad-attention" #look in the wiki for what you actually need
Command Line Arguments and Settings · AUTOMATIC1111/stable-diffusion-webui Wiki · GitHub
Now just start the webui and let it do it’s magic
./webui.sh
If you get a segmentation fault error, you have the wrong HSA_OVERRIDE_GFX_VERSION
value. Search the internet for your GPU model and change the webui-user.sh
file.
https://github.com/DaniAndTheWeb/sd-data-amd-gpu/blob/main/HSA_GFX_VERSION.MD
There is currently a strange error with an import in one of the pip libraries, which will be fixed with the next update I think. Here is what helped me.
If the link is down, this is what worked
sed -i 's/from torchvision.transforms.functional_tensor import rgb_to_grayscale/from torchvision.transforms.functional import rgb_to_grayscale/' venv/lib/python3.10/site-packages/basicsr/data/degradations.py
Again, you can create a .desktop file in ~/.local/share/applications/
and name it stable-diffusion.desktop
Open it with a text editor (Kate) and replace everything with
[Desktop Entry]
Categories=Distrobox;System;Utility
Comment[en_US]=via Ubuntu ROCm distrobox
Comment=via Ubuntu ROCm distrobox
Exec=/usr/bin/distrobox enter rocm -- ./webui.sh
GenericName[en_US]=Start Stable Diffusion in default browser
GenericName=Start Stable Diffusion in default browser
Icon=
Keywords=distrobox;
MimeType=
Name[en_US]=Stable Diffusion
Name=Stable Diffusion
NoDisplay=false
Path=~/Documents/Git/stable-diffusion-webui/
StartupNotify=true
Terminal=true
TerminalOptions=
TryExec=/usr/bin/distrobox
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=
Don’t forget to change the Path, if you installed Stable Diffusion differently.
Good luck