How to install AMD ROCm for OpenCL support

Saw that. Will now setup Tumbleweed on a spare drive and test on a live system. Plenty of new stuff to learn (btrfs + snapshots).
Thank you for your replies

1 Like

I did a Tumbleweed minimal installation and just added Plasma Base Theme.

rocm now installs with a version number named folder, like “rocm-3.3.0”
In order to make step 3 of the list work, you have to

ln -s /opt/rocm-3.3.0 /opt/rocm

else the linker won’t find the libraries.

As I started out with a slim installation, I needed to install

zypper install clinfo Mesa-libOpenCL

clinfo worked and found the device. OpenCL activated incl. Image support

Maybe it helps some other newbies like myself

1 Like

Another question:

Do I have to run ldconfig now every time zypper dup pushes a new kernel version?

ldconfig is only needed if you update rocm …

1 Like

I recently went through the process of getting ROCm working on Arch Linux and documented the steps here - fyi if anyone else is using Arch.

1 Like

I use two desktops and I finally found the time to do a planed hardware swap that required the disassembly of both systems.
Preparing the fresh install of my linux system, I realized that OpenSuse has released Leap 15.2.
Initially I wanted to set up a Tumbleweed System but hey, why not give it a try at this point?!

Installation went flawlessly and I started with setting up opencl with rocm.
I followed this instruction, almost remembered that /opt/rocm needs to be linked to /opt/rocm-x.x.x and fired up clinfo.
1 platform found but 0 device

Adding my user to video group as described on rocm documetation for a complete setup did not help.

Than I realized that in the

http://repo.radeon.com/rocm/zyp/zypper/

repo, the required files are listed in a versioned format and in a non versioned format.
Here as an example zypper se -s rocm-opencl

S  | Name                 | Typ   | Version     | Arch   | Repository
---+----------------------+-------+-------------+--------+--------------------
   | rocm-opencl          | Paket | 2.0.20191-1 | x86_64 | Radeon Open Compute
   | rocm-opencl-dev3.5.0 | Paket | 2.0.20191-1 | x86_64 | Radeon Open Compute
   | rocm-opencl-devel    | Paket | 2.0.20191-1 | x86_64 | Radeon Open Compute
i+ | rocm-opencl3.5.0     | Paket | 2.0.20191-1 | x86_64 | Radeon Open Compute

I went for the versioned files but I really couldn’t find a point in the documentation that explains this.
So the first question is:
Does anyone know?

Next I tried sudo clinfo and voilà, I got opencl support up and running. Without elevated rights the problem remained. Looks like I had a permission problem. I checked all file’s permissions but everything looked fine.
One very good solution to troubleshoot I found on github was to use strace.

strace -f clinfo 2> trace1.txt

that pretty much wrote everything that happened in this text file. I did the same with elevated rights and wrote it in another file and loaded both into a compare view.
The point where clinfo ran into problems was trying to access /dev/kfd.
A quick listing showed that on my install /dev/kfd had permissions set to 600. I found a github thread, a year old, where someone ran into the same problem with an ubuntu system.
Solution presented was, as /dev/kfd is controlled by udevd, to write a udev rule.
I created /etc/udev/rules.d/81-kdf.rules and added the line

KERNEL=="kfd", MODE="0660", GROUP="video", TAG+="uaccess"

I also followed the advice to create a new initramfs. On OpenSuse it is

sudo mkinitrd

Opencl now does work.

My second question here is
As I have not ran into that problem before, I am wondering if this should be considered a bug and if it should be adressed to rocm or OpenSuse?

ln -s /opt/rocm-3.9.0 /opt/rocm

sudo usermod -a -G video $LOGNAME

On Ubuntu Focal the following worked for me:

darktable: 3.4
kernel: 5.4.0-58-generic
rocm: 4.0

Purge all existing rocm packages

sudo apt purge $(awk '$1 == "Package:" { print $2 }' /var/lib/apt/lists/repo.radeon.com*)

Edit /etc/apt/sources.list.d/rocm.list

deb http://repo.radeon.com/rocm/apt/debian/ xenial main
sudo apt update
sudo apt install rocm-opencl rocminfo clinfo

Edit /etc/ld.so.conf.d/hsa-rocr-dev.conf

/opt/rocm-4.0.0/hsa/lib
/opt/rocm-4.0.0/lib
/opt/rocm-4.0.0/opencl/lib
sudo ldconfig
sudo usermod -a -G render,video $LOGNAME

Re-Login.

Test with:

/opt/rocm-4.0.0/opencl/bin/clinfo
/opt/rocm-4.0.0/bin/rocminfo
clinfo
darktable-cltest

I’m on Ubuntu 20.04 using an AMD RX 5700 XT and it seems that my ROCm-4.0.0 installation works fine, see

> clinfo | grep Image
  Image support                                   Yes

And I see that the GPU is used during some operations in DT, however I’m still getting this message when starting DT:

dlerror: libnvidia-opencl.so.1: cannot open shared object file: No such file or directory~~

Is that something to worry about?

UPDATE: nevermind the noise, I had a nvidia leftover in /etc/OpenCL/vendors, after deleting it the message went away.

Has anyone got DaVinci Resolve to work with ROCm?
For version 16 it doesn’t render the video viewers. It’s supposedly an OpenGL bug.
For version 17 it crashes on doing anything media related (like importing, loading etc).

I’ve tested this with ROCm 4.0 and previous.

1 Like

What is better, OpenCL via the AMDGPU-pro drivers, or ROCm?

I’m on Kubuntu 20.04, and I’m currently using OpenCL via the AMDGPU-Pro drivers.

I’m using ROCm since years now :slight_smile:

1 Like

@asn, anyway, I returned by crashing AMD RX580 for a refund, and I’ve now got an Nvidia GTX 1660 on it’s way instead :slight_smile:

After struggling for a while, I found two rather easy ways to install ROCm.

openSUSE Leap 15.2 5.3.18-lp152.66-default
Radeon RX 5600 XT
amdgpu + rocm 4.1.0

Method 1) DKMS module
The easiest is to just follow the instructions for the dkms kernel module.
You may have to add the hsa-ext-rocr-dev package. After a reboot everything worked. The drawback is that this will up take ca. 3 GB of disk space but then after a kernel update you won’t need to worry.

Method 2) As described in this thread
a) Add the repo as instructed by Andreas in his first post.
b) Install rocm-opencl hsa-ext-rocr-dev hsamkt-roct comgr (some of this might be automatically installed as dependency, but I can’t remember what)
c) ln -s /opt/rocm-4.1.0 /opt/rocm (that’s the only fix I had to do)
Unfortunately clinfo only worked as admin. There may still be some fix to do, as suggested by wallie.

Method 3) amdgpu-pro
Finally, I also tested the amdgpu-pro module (amdgpu-pro-20.50-1234663-sle-15.2) but while both clinfo and darktable-cltest showed Image support, darktable with activated openCL froze my computer when opening any image.

After updating Leap 15.2 today, the opencl support was gone… I had to manually remove and reinstall rocm-dkms 4.2.0 to make it work again. It required some strange perl package in the process, which I had to pull from an experimental repo.

Honestly, with this kind of issues, I am not surprised that Linux is not gaining traction on the desktop… If this happens again, I think I’m back to Windows.

I never had to install the dkms module. See my initial post! Installing dkms means you’re replacing the SUSE kernel …

I followed your advice earlier and was able to runc rocm 3.x, so your instructions are fine. Thanks a lot for that! However, it broke somewhere around version 4.0 and after spending countless hours to no avail, I settled on the dkms install.

That being said, you will have to admit that all these solutions involve different levels of messing with the system or “Gefrickel” (as we like to say in German), which is a real PITA and an insurmountable barrier for any less technically versed user. In addition, although I am not running a bleeding edge rolling release, I still have to worry after each update how many hours I’ll have to spend to make it work again…

Documenting another variant that works

Graphics: Navi 10 [Radeon RX 5600 OEM/5600 XT / 5700/5700 XT]

OS: Ubuntu 20.04.3 LTS
Kernel: 5.11.0-34-generic #36~20.04.1-Ubuntu (newer PPA Kernels will not work)
darktable: 3.6.0-1.1 from OBS

amdgpu-pro driver will conflict with this method and should not be installed.

Download rocm GPG key (apt-key is depreciated)

curl -s https://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/rocm.gpg >/dev/null

Edit /etc/apt/sources.list.d/rocm.list

deb [arch=amd64 signed-by=/usr/share/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/4.2/ ubuntu main

Note the rocm 4.2 version to work with Darktable 3.6

sudo apt-get update
sudo apt-get install rocm-opencl

Edit /etc/ld.so.conf.d/hsa-rocr-dev.conf

/opt/rocm-4.2.0/opencl/lib
/opt/rocm-4.2.0/hsa/lib
/opt/rocm-4.2.0/lib

Run

sudo ldconfig
sudo usermod -a -G render,video $LOGNAME

Re-Login and test with:

/opt/rocm-4.2.0/opencl/bin/clinfo
Number of platforms:				 1
  Platform Profile:				 FULL_PROFILE
  Platform Version:				 OpenCL 2.0 AMD-APP (3275.0)
  Platform Name:				 AMD Accelerated Parallel Processing
  Platform Vendor:				 Advanced Micro Devices, Inc.
  Platform Extensions:				 cl_khr_icd cl_amd_event_callback 


  Platform Name:				 AMD Accelerated Parallel Processing
Number of devices:				 2
  Device Type:					 CL_DEVICE_TYPE_GPU
  Vendor ID:					 1002h
  Board name:					 Navi 10 [Radeon RX 5600 OEM/5600 XT / 5700/5700 XT]
[...]
darktable-cltest
[...]
0.341776 [opencl_init] OpenCL successfully initialized.
0.341777 [opencl_init] here are the internal numbers and names of OpenCL devices available to darktable:
0.341779 [opencl_init]		0	'gfx1010:xnack-'
0.341781 [opencl_init] FINALLY: opencl is AVAILABLE on this system.
1 Like