Skip to content

Instantly share code, notes, and snippets.

@antoninkriz
Last active April 20, 2020 11:52
Show Gist options
  • Save antoninkriz/790160afbe54a61838cf684abc761c27 to your computer and use it in GitHub Desktop.
Save antoninkriz/790160afbe54a61838cf684abc761c27 to your computer and use it in GitHub Desktop.
Tutorial on how to run Folding@Home client on a PC with AMD GPU

How to run Folding@Home on Linux on AMD GPU (Ubuntu 18.04)

What is this

Tutorial on how to run Folding@Home client on a PC with AMD graphics card and how to potenitally solve following errors:

  • BAD_WORK_UNIT (114 = 0x72)
  • Failed to start core: OpenCL device matching slot 1 not found, try setting 'opencl-index' manually
  • Error initializing context: clGetPlatformIDs (-1001)
  • OpenCL: Not detected: clGetDeviceIDs() returned -1
  • Received short response, expected 512 bytes, got 0

The tutorial

1 - Completely remove F@H packages

F@H does some hardware autoconfiguration magic on a first run, so let's go for a clean installation, just to be sure.

$ apt remove --pruge FAH*

2 - Install newest proprietary AMD GPU drivers

F@H utilizes OpenCL and AFAIK only proprietary amd-gpu-pro drivers have a properly working implementation. Before blindly copy pasting these lines, check if there isn't a newer version:
https://www.amd.com/en/support

$ wget https://drivers.amd.com/drivers/linux/amdgpu-pro-20.10-1048554-ubuntu-18.04.tar.xz
$ tar -Jxvf amdgpu-pro-20.10-1048554-ubuntu-18.04.tar.xz
$ cd amdgpu-pro-20.10-1048554-ubuntu-18.04
$ ./amdgpu-install --pro --opencl=pal,legacy --headless -y
$ reboot

3 - Install newset F@H client

Before blindly copy pasting these lines, check if there isn't a newer version:
https://foldingathome.org/alternative-downloads/

$ wget https://download.foldingathome.org/releases/public/release/fahclient/debian-stable-64bit/v7.6/fahclient_7.6.9_amd64.deb
$ wget https://download.foldingathome.org/releases/public/release/fahcontrol/debian-stable-64bit/v7.6/fahcontrol_7.6.9-1_all.deb
$ sudo dpkg -i fah*

4 - Add fahclient user to the video group

Only users which are in the video group have an access to the GPU, so you need to add the fahclient user (which is created after F@H installation automatically)

$ sudo adduser fahclient video

5 - Force FAHClient to start using systemctl instead of init.d

F@H has some bug when starting using init.d that assigns no permission and no groups to the process. Running FAHClient using systemctl should fix that.

Create a new file with exactly this name (other name will prevent overloading the original init.d script) ...

$ sudo nano /etc/systemd/system/FAHClient.service

... and paste and save this config ...

[Unit]
Description=Folding@Home Client
WantedBy=graphical.target

[Service]
Type=simple
ExecStart=/usr/bin/FAHClient /etc/fahclient/config.xml --daemon
User=fahclient
WorkingDirectory=~

[Install]
WantedBy=graphical.target

... and update systemctl so the process can start on boot properly.

$ sudo systemctl daemon-reload
$ sudo systemctl enable FAHClient.service
$ sudo systemctl start FAHClient.service
$ sudo systemctl restart FAHClient.service

6 - Edit the F@H configuation

Wipe and open the old config...

$ sudo echo "" > /etc/fahclient/config.xml
$ sudo nano /etc/fahclient/config.xml

... and paste and save this configuration so F@H detects your GPU properly.

<config>
  <!-- Folding Slot Configuration -->
  <client-type v='beta'/>

  <!-- Network -->
  <proxy v=':8080'/>

  <!-- Slot Control -->
  <power v='full'/>

  <!-- User Information -->
  <!-- Your passkey goes here. Leave blank if not used.-->
  <passkey v='YOUR_PASSKEY'/> <!-- !!! CHANGE THIS !!! -->
  <team v='245800'/>
  <!-- Your username goes here. -->
  <user v='YOUR_USERNAME'/> <!-- !!! CHANGE THIS !!! -->

  <!-- Folding Slots -->
  <slot id='0' type='CPU'/>
  <slot id='1' type='GPU'/>
</config>

7 - Done

Just reboot and everything should work, hopefully.

$ reboot

FAQ

Where does this work

I have no idea. This was done on Ubuntu 18.04, Kernel 5.3.0-46, AMD RX 570, but this tutorial other Linux systems should work too (some changes may be needed - for example packages URLs).

Where does it not work?

No idea. Possibly integrated and older GPUs, older systems, ... This also won't work on GPUs that are not supported by the amd-gpu drivers and F@H.

Something broke and something does not work!

🇫. You've probably f'd up the driver installation. Boot to safe mode, preferably using older Kernel and unsitnal the drivers, thn try again.

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment