[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.

10 Likes

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

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.

1 Like

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:

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.

Excellent you are a life saver . Yestarday i came from manjaro to fedora caz this amd proprietory driver were my system not boot at all and was super upset with it and decided to jump two or three distros if nothing works go back to windows caz i really need this because open drivers are not able to run the software .

1 Like
  Installing       : libglvnd-opengl-1:1.3.1-1.fc32.x86_64                1/104 
  Installing       : libGLEW-2.1.0-6.fc32.x86_64                          2/104 
[...]
  Installing       : blender-fonts-1:2.83.1-1.fc32.noarch                97/104 
  Running scriptlet: amdgpu-core-20.30-1109583.el8.noarch                98/104 
ERROR: This package can only be installed on EL8.
error: %prein(amdgpu-core-0:20.30-1109583.el8.noarch) scriptlet failed, exit status 1

Error in PREIN scriptlet in rpm package amdgpu-core
  Installing       : mesa-amdgpu-libOSMesa-1:20.1.0-1109583.el8.x86_6    99/104 
error: amdgpu-core-0:20.30-1109583.el8.noarch: install failed

  Running scriptlet: mesa-amdgpu-libOSMesa-1:20.1.0-1109583.el8.x86_6    99/104 
  Installing       : vtk-8.2.0-14.fc32.x86_64                           100/104 
  Installing       : opencv-contrib-4.2.0-7.fc32.x86_64                 101/104 
[...]
Failed:
  amdgpu-core-20.30-1109583.el8.noarch                                          

Error: Transaction failed

Followed your instructions, but this is what happens when I try to install Blender. What now?

EDIT: Also, when I try to run DaVinci Resolve, I get “error while loading shared libraries: libGLU.so.1: cannot open shared object file: No such file or directory”. When I install the Mesa version, I get a white box where the splash screen would go, and then the program freezes. I do not think DaVinci Resolve works with Mesa in any way.

Since I can’t edit my reply after 2 days (??) I will make a new reply instead. Since I can’t seem to use Blender or Resolve this way, I will use Ubuntu since AMD does provide a package specifically for that.

The original post said,

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)

So the ugly failed transaction messages you posted are normal for this hacky workaround. Did you test Blender? Does darktable-cltest work for you? I tried installing Blender on my machine and it at least seemed to think OpenCL was available on my Radeon RX 560. I wasn’t willing to run the proprietary binary installer for DaVinci Studio.

1 Like

That’s what I did. But it sometimes requires putting up with a tediously-old version of Ubuntu. The pattern is that AMD provides AMDGPU-PRO for long-term-support distros only: CentOS (Fedora’s LTS) and one Ubuntu every two years.

1 Like

Is this the permanent installation plan for enabling OpenCL with GPUs from the only GPU company with a decent open source relationship and drivers?

I’ve been fighting with OpenCL in Fedora for a long time, 10+ years w/ AMD hardware. I think the answer to your question is ‘no’. For example, some of the information in this thread regard specific applications, like Blender.

But, for the time being, yes, you must add the OpenCL components from AMDGPU-PRO for maximum compatibility and performance, which is still not total.

Some older AMD hardware is supported via the fully OSS OpenCL stack and does not require any AMDGPU-PRO support. Last I heard, AMD is still promising full functionality in the OSS stack, eventually. But, no ETA after many years.

1 Like

I have updated this guide for latest AMD repos and correct packages here - https://www.reddit.com/r/Fedora/comments/m2il41/guide_installing_opencl_alongside_mesa_drivers/

This guide won’t work anymore with latest AMD repositories.

2 Likes