[GUIDE] Install amdgpu-pro OpenCL in Fedora 32

Yesterday I installed Fedora 32 and It’s been great, except for the OpenCL part in my Radeon card… So as I could not find any decent guide in the internet on how to do this on Fedora 32 I’ve decided to write one myself. This will install the necesary files from the amdgpu-pro driver to use OpenCL in Fedora but keep the open source video driver that comes with the system.

First download the latest driver from the AMD website for RedHat/CentOS 8.xx

At the time of writing this it’s driver 20.20. Then uncompress it into the /var/local directory, and rename the directory to amdgpu (or whatever you want, just make sure to remember it for creating the local repo)

cd /var/local
tar xf /path/to/amdgpu-pro-xx-xx-xxxxxx-rhel-x.x.tar.xz
mv amdgpu-pro-xx-xx-xxxxxx-rhel-x.x amdgpu

Now create the local repo file in /etc/yum.repos.d/amdgpu.repo containing the following lines (note the name of the directory in /var/local/):

[amdgpu]
name=AMDGPU Packages
baseurl=file:///var/local/amdgpu/
enabled=1
skip_if_unavailable=1
gpgcheck=0
cost=500
metadata_expire=300

And now just install the necesary packages for getting OpenCL to work:

If you have a POLARIS card or older (I tested this because I have 580):
dnf install libdrm-amdgpu libdrm-amdgpu-common clinfo-amdgpu-pro opencl-amdgpu-pro-comgr amdgpu-pro-core opencl-orca-amdgpu-pro-icd libopencl-amdgpu-pro

If you have a VEGA card or newer (I didn’t test this but it should work in theory):
dnf install libdrm-amdgpu libdrm-amdgpu-common clinfo-amdgpu-pro opencl-amdgpu-pro-comgr amdgpu-pro-core opencl-amdgpu-pro-icd libopencl-amdgpu-pro

In either case it will fail to install the amdgpu-core dependency but it doesn’t matter because it’s not needed for using OpenCL. (Plus we want to keep the amdgpu driver that’s already included in the kernel)

Now at last, if you have the Mesa runtime for OpenCL installed just rename the mesa.icd file to something else in /etc/OpenCL/vendors so the system uses the AMD driver OpenCL runtime.

mv /etc/OpenCL/vendors/mesa.icd /etc/OpenCL/vendors/mesa.icd.bk

And that’s it! If you need to upgrade the OpenCL runtime you could theoretically replace the /var/local/amdgpu files with the files from the newest RedHat driver and run a normal upgrade using dnf.

Here is the output of the darktable-cltest running on my machine for those who are curious.

4 Likes

Please consider writing this up as a quick-doc like the one we have for Nvidia:

https://docs.fedoraproject.org/en-US/quick-docs/how-to-set-nvidia-as-primary-gpu-on-optimus-based-laptops/

You can start here:

https://pagure.io/fedora-docs/quick-docs

2 Likes

First question: why is libdrm-amdgpu needed?

Second question: what is wrong with OpenCL in OSS stack? If you had to move mesa.icd out of the way, then it sounds like it’s working.

For VEGA and POLARIS cards, my understanding is that none of those are necessary. This is because the OSS stack includes proper opencl information provided by AMD upstream. Have you tried che-mesa copr? If they are not in F32, I believe the required data is in the latest stable Mesa.

I cannot remember for sure, but I think this is how I had my 580 card running OpenCL; I recently got rid of my 580. However, you can see the required opencl code exists in the libclc package (/usr/lib/clc/*mesa*.bc – POLARIS 10 &11 cards are there).

I found this information while researching the NAVI family, which is what I have, now. I found that NAVI was singled out as the only unsupported card family. And, I can confirm that the problems with OSS opencl appear to be directly related to this, at least. For example, clinfo gives an error sighting this missing file.

Ah, okay, you want something special for darktable, right? “Image support”? Okay, I don’t know anything about that.

Yeah, for me the open source Mesa implementation that comes with Fedora doesn’t work with the software that I needed. So I have only two options, the amdgpu-pro implementation of OpenCL and ROCm. I tried ROCm first, but couldn’t for the life of me get it working. So installing the closed source implementation for RedHat in a janky way was the only thing that worked for me. If anyone knows how to get ROCm working please tell us how, I would rather have that than the AMD blob.

Hmm, I don’t know if writing documentation about a janky workaround is a good idea. This packages (although they work fine) appear as broken when running dnf repoquery --unsatisfied. So there is no guarantee that this will work for future versions of the AMD driver or Fedora. It might not even work properly with other people’s setups.

Ah, then we probably remove the [Guide] from the title. It only works for you, so at best people should use this as a reference?

Or change it to something referencing darktable - it is a quite popular raw image processor (the best, in my opinion), and helping people with enabling OpenCL for it is a very good idea.

I mean, this is a guide to install OpenCL and use it for any generic purpose (I just inserted the output of the darktable command to show that the gpu was recognized as a valid OpenCL device). What I was saying is that maybe It’s not a great idea writing official documentation about installing something that is not officially supported by AMD to run on Fedora.

All good points, but, to be fair to OP, this is a problem that has existed for over a decade and no one has really been able to solve it in a consistent way. It is a major deficiency and can certainly be mostly blamed on AMD. Fedora + AMD users live in this gray area all the time and it’s extremely frustrating. I’ve been waiting 10 years for things to work, hoping the next kernel release will have all the pieces I need.

The distribution of RPMs is a significant improvement, even though Fedora is not supported. I wouldn’t call it “janky”… do you remember what we used to have to do to get Catalyst installed?! What isn’t supported is the newer kernels and rapid distro upgrades that is part of the Fedora cycle. RHEL is supported, so OP’s approach is certainly not strange or unreasonable. As you can guess, I’ve been using it, myself, for nearly a year now.

As I mentioned before, all the reading I have done over the past five years points to AMD treating the OSS stack as their “supported” drivers for fedora and similar distributions. That is also why I wanted to bring it up here. Sorry it didn’t work, but at least it is clear that only a particular feature is broken in OSS OpenCL, not all of it.

Several people have written similar guide-like blog posts over the past decade, which have needed to be continually updated as the AMD installer evolves. I think it would be great if there was a place for this community knowledge to be shared, here. Never heard of quick-docs, but sounds great.

2 Likes

That’s not necessary for quick-docs. Quick-docs are short write ups on doing things on Fedora. They even include things like using spotify etc. which are all not officially supported. It’s up to you, though. :slight_smile:

https://docs.fedoraproject.org/en-US/quick-docs/

Thanks for the guide. Yes Darktable and Blender are works now but Davinci Resolve still crashing. Any thoughts on that? Forgot to mention, I’m with Vega 64.