How to install AMD ROCm for OpenCL support

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

A heads-up for anyone running Ubuntu 20.04 HWE (or any Ubuntu with kernel 5.13): The headers in the 5.13 kernel conflict with the amdgpu-dkms driver installed by ROCm. You will need to backdate to a 5.11 series kernel.

Other than that, ROCm 4.5 has been working well for me (Ryzen 9 3900X, Sapphire Nitro+ RX 5700XT, Ubuntu Studio 20.04, Darktable 3.8.0). I tripped over this issue when I did a routine ‘apt-get upgrade’ and attempted to update to ROCm 4.5.2 last night.

Yes, this has been reported on the AMD / gitlab github repos:

The following kernels work just fine on ubuntu: 5.4.0, 5.10.0, 5.11.0

1 Like

Following combinations works for me on a AMD Radeon RX 5600M / Navi 10 Laptop

  • Ubuntu 22.04.1 LTS
  • darktable 4.0.0 from OBS
  • rocm-opencl 5.2.1
/etc/apt/sources.list.d/rocm.list
deb [arch=amd64 signed-by=/usr/share/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/5.2.1/ ubuntu main
[opencl_init] OpenCL successfully initialized.
[opencl_init] here are the internal numbers and names of OpenCL devices available to darktable:
[opencl_init]		0	'gfx1010:xnack-'
[opencl_init]		1	'gfx90c:xnack-'
[opencl_init] FINALLY: opencl is AVAILABLE on this system.