Setting up Folding@Home to use OpenCL with the AMDGPU drivers

I finally figured out how to get OpenCL working on my RX 580 for Folding@Home and I wanted to document the process.

My goals were to get a working OpenCL situation but still use the open source video drivers. So some of this is retrospective and from memory so hopefully I remember everything.

First you need to install the AMDGPU drivers for OpenCL. The best candidate right now are the ones for RHEL/CentOS 8.1:

At the time of writing this the driver link is:

Download the archive and expand it into /var/local:

cd /var/local
tar xf /path/to/amdgpu-pro-19.50-967956-rhel-8.1.tar.xz
mv amdgpu-pro-19.50-967956-rhel-8.1 amdgpu

Now you can download the repo file I made for it:

cd /etc/yum.repo.d/
curl -LO https://hobbes1069.fedorapeople.org/amdgpu/amdgpu.repo

If everything is correct you should see AMDGPU in your repolist:

dnf repolist

Now you don’t need many of the packages to just get OpenCL support, here’s what I have installed:

# rpm -qa | grep amdgpu
libdrm-amdgpu-2.4.99-967956.el8.x86_64
libdrm-amdgpu-common-1.0.0-967956.el8.noarch
clinfo-amdgpu-pro-19.50-967956.el8.x86_64
opencl-amdgpu-pro-comgr-19.50-967956.el8.x86_64
amdgpu-pro-core-19.50-967956.el8.noarch
opencl-orca-amdgpu-pro-icd-19.50-967956.el8.x86_64
libopencl-amdgpu-pro-19.50-967956.el8.x86_64

Since my card is the the previous generation I have “opencl-orca-amdgpu-pro-icd” installed, if you have the latest cards you want opencl-amdgpu-pro-icd.

NOTE: it may want to pull in dkms and dkms-firmware and build the module. It should fail as it hasn’t been updated for 5.x.x kernels and you can dnf erase the dkms packages afterwards.

No here’s where it gets stupid. Every library that supports an OpenCL pathway will install a file into /etc/OpenCL/vendors. Most programs are too stupid to try all of them and see which one works so when the first one fails, it just gives up, as is the case with Folding@Home.

So here’s what you need to do, go into /etc/OpenCL/vendors and rename the files you don’t want to use. Here’s what mine looks like now:

# ll /etc/OpenCL/vendors/
-rw-r--r--. 1 root root 20 Dec 17 23:11 amdocl-orca64.icd
-rw-r--r--. 1 root root 29 Jul 21  2018 intel-beignet.icd_backup
-rw-r--r--. 1 root root 19 Dec 18 15:58 mesa.icd_backup
-rw-r--r--. 1 root root 16 Sep 26  2019 pocl.icd_backup

So now the amdocl-ora64 is the only “supplier” of OpenCL on my system. At this point running clinfo should work and only show one platform:

# clinfo -l
Platform #0: AMD Accelerated Parallel Processing
 `-- Device #0: Ellesmere

Now we’re ready to install Folding@Home (but we’re not done yet!)

Go here and download/install all three packages of the latest version for RHEL/CentOS/Fedora (hint: it’s really for EL and we have to fix that):

https://foldingathome.org/start-folding/

After installing all 3 packages there’s a few things we need to do before starting FAHControl.

  1. It’s not compatible with Python3 which is the default on Fedora 31 and up.

     vi /usr/bin/FAHControl
    

    and change the first line from:

     #!/usr/bin/python
    

    to

     #!/usr/bin/python2
    
  2. It uses a SysV init script to start FAHClient even though just about everything from CentOS 7 and up uses SystemD. This is important because FAHClient doesn’t suid to the fahclient user correctly using the SysV compatibility layer of SystemD so we need to create our own SystemD unit file. Luckily I’ve already done that.

     cd /etc/systemd/system
     curl -LO https://hobbes1069.fedorapeople.org/amdgpu/FAHClient.service
    

    The naming is important otherwise SystemD will create the service file from the /etc/init.d file which causes the problem we’re trying to correct. By creating a service file with the same name we stop that behavior.

  3. We need to add fahclient to the “render” group so it as access to the correct devices in /dev.

     usermod -a -G render fahclient
    

Theoretically it’s possible to get everything recognized without rebooting but now is probably a good time to reboot your computer anyway since we’ve made a lot of changes.

REBOOT YOUR COMPUTER

At this point things should hopefully work, so try launching FAHControl and see what happens!

NOTE: FAHControl only attempts to test for GPU units on the first launch. If it doesn’t find one it doesn’t matter how many time you check the “System Info” tab or create a new Folding Slot. It won’t try again unless you edit /etc/fahclient/config.xml and remove the line near the top that has something like

   <GPU="false">

That’s all I can remember for the last couple of days banging my head against the wall but hopefully someone finds this usefull.

Thanks,
Richard

2 Likes

Thanks for the writing this up. After banging my head against a wall trying various things your setup steps got things working for me (and so there are now another two RX580 GPUs working on the COVID-19 problem!)

Glad it helped out! I need to update it a little but nothing critical. I also have a Nvidia based system for home theatre so I set it up too. I found out that you can remove the packages that provide the extra OpenCL vendor files:

# dnf erase /etc/OpenCL/vendors/<unwanted vendor>

Dnf of course knows what package owns that file and will remove the whole thing.

Thanks,
Richard

ROCm also works in version 3.3

Any known performance difference between the two?

Would anyone be willing to create a podman container which would include everything necessary for running F@H with Radeon cards (Mesa drivers) on Fedora hosts?

@hobbes1069 Thanks for the guide, however, I’m having a little difficulty. When I tried to install the driver ./amdgpu-pro-install I get the following error:

Ignoring repositories: amdgpu
Last metadata expiration check: 1:39:20 ago on Sat 16 May 2020 01:06:06 PM EDT.
No match for argument: amdgpu-dkms
No match for argument: amdgpu
No match for argument: amdgpu-pro
No match for argument: vulkan-amdgpu-pro
Error: Unable to find a match: amdgpu-dkms amdgpu amdgpu-pro vulkan-amdgpu-pro

Thus I cannot proceed and unfortunately OpenCL is not detected, obviously.

As my instructions never say to run their installer I would recommend you start over at the top :slight_smile:

@hobbes1069 I redid everything.

clinfo -l

Platform #0: AMD Accelerated Parallel Processing

-- Device #0: gfx900

I got the following error:

Running transaction

Preparing : 1/1

Running scriptlet: amdgpu-core-20.10-1048554.el8.noarch 1/7

ERROR: This package can only be installed on EL8.

error: %prein(amdgpu-core-0:20.10-1048554.el8.noarch) scriptlet failed, exit status 1

Error in PREIN scriptlet in rpm package amdgpu-core

Installing : amdgpu-pro-core-20.10-1048554.el8.noarch 2/7

error: amdgpu-core-0:20.10-1048554.el8.noarch: install failed

Also, I’ve got these installed:

rpm -qa | grep amdgpu

libdrm-amdgpu-2.4.100-1048554.el8.x86_64

amdgpu-pro-core-20.10-1048554.el8.noarch

libopencl-amdgpu-pro-20.10-1048554.el8.x86_64

opencl-amdgpu-pro-comgr-20.10-1048554.el8.x86_64

opencl-amdgpu-pro-icd-20.10-1048554.el8.x86_64

libdrm-amdgpu-common-1.0.0-1048554.el8.noarch

In FAHControl, System Info, I get:

OpenCL Not detected: clGetDeviceIDs() returned -1

So clinfo looks good. The errors are normal since you’re not actually running EL 8.

What card do you have? Do you need the orca icd package or the latest (for 5000 series) package?

@hobbes1069 Thanks! I have the Vega 64. Is that considered “old” and I’ll need orca just like in your post?

clinfo -l
Platform #0: Clover
-- Device #0: Radeon RX Vega (VEGA10, DRM 3.36.0, 5.6.12-300.fc32.x86_64, LLVM 10.0.0) Platform #1: AMD Accelerated Parallel Processing – Device #0: gfx900

Not sure, but might as well swap out the packages and see if it works.

I noticed today that my work units were failing, updating the amdgpu drivers and restarting the service fixed it for me.

$ sudo restart FAHClient.service

1 Like