How to install AMD ROCm for OpenCL support

To install ROCm with OpenCL and Image Support, you have do the following five steps:

  1. Add the ROCm (>= 3.1) repository to your package manager. You can find the repositories for Debian/Ubuntu, Fedora/RHEL or openSUSE/SLE here.

    For example to add a zypper repository on openSUSE create the following file:

    /etc/zypp/repos.d/rocm.repo

    with the content:

    [rocm]
    name=Radeon Open Compute
    enabled=1
    autorefresh=0
    baseurl=http://repo.radeon.com/rocm/zyp/zypper/
    type=rpm-md
    
  2. Install the required packages using:

    zypper in rocm-opencl hsa-ext-rocr-dev
    
  3. Create /etc/ld.so.conf.d/rocm-opencl.conf with the following content:

    /opt/rocm/hsa/lib/
    /opt/rocm/lib
    /opt/rocm/lib64
    /opt/rocm/opencl/lib/x86_64
    
  4. To load the new paths into the linker run: ldconfig

  5. And last but not least create an OpenCL ICD file using:

    echo libamdocl64.so > /etc/OpenCL/vendors/amdocl64.icd
    
  6. Now you can run clinfo to verify that it is working. Check for Image Support, this is what you need for darktable or RawTherapee.

6 Likes

ROCm 3.1 is out and works just fine.

What about this OpenCL / Local Laplacian issue with Rocm?

Its a bug with the rocm drivers.

The bug is still open …

Just checked the rocm repo and saw that V3.3 came out March 29th.

Did anyone try it out and has the bug been fixed?

I am still on Ubuntu 18.04.4 with parts of the amdgpu-pro driver so can’t test myself but as I am still eyeballing with Tumbleweed I am interested.

The bug linked above is still open.

but otherwise Tumbleweed +rocm 3.3 are working together as per your instructions?

Yes, works just fine. Should work with Ubuntut too but I haven’t tried. There are apt-get repos too.

1 Like

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

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