Using Folding@Home on openSUSE with Docker

I’m going to go ahead and tag @CubicleNate because I know he was having issues with this.

The RPM package for Folding@Home was designed with only Red Hat-based systems in mind, leaving us openSUSE users powerless in the face of unsolvable dependency issues. However, in this age of virtualization, we can rise above our circumstances with the power of containers!

In this tutorial, I will go over how to get Folding@Home up and running on openSUSE using Docker. No previous experience with Docker is needed, and you can even adapt these instructions to other Linux distributions you wish to run Folding@Home in a container. I have only tested this on Tumbleweed, but it should work on Leap as well.

Setting up Docker

To get Docker up and running, you need to install the docker package, start the systemd service, and add your user to the docker group.

sudo zypper install docker
sudo systemctl enable --now docker.service
sudo usermod -aG docker <username>

Log out and back in again for your addition to the group to take effect.

Running the container

Nickolay Yurin has already created a container for Folding@Home and posted the source over on GitHub. Unfortunately, this container only supports CPU, not GPU, loads, but we’ll get to that in a minute. Per the README, running the container is as easy as this rather lengthy command:

docker run -d \
  --name folding-at-home \
  -p 7396:7396 \
  -p 36330:36330 \
  -e USER=Anonymous \
  -e TEAM=0 \
  -e ENABLE_GPU=false \
  -e ENABLE_SMP=true \
  --restart unless-stopped \
  yurinnick/folding-at-home \
  --allow 0/0 \
  --web-allow 0/0

Those of you who read the README may note that (a) there should not be a -d on the first line, and (b) the last two lines are not necessary unless you want to access the web control panel from machines other than the host. I have added the -d because it detaches the container from your current session so that you can close the terminal or use it for other things, and I was unable to access the control panel even from my local machine without the last two lines.

You can change the username and team name to whatever you desire, although you should consider joining the Linux for Everyone team (240869)!

Automating the Container

The above command will leave Folding@Home working in the background for as long as your computer is on. However, you will have to run the command again if ever you need to reboot (a fairly common occurance for us Tumbleweed users.) Thankfully, Marc Nuri has put a very nice tutorial up on his blog about automating a Docker container using systemd, allowing you to launch Folding@Home at system startup and manipulate it with the familiar systemctl command. Create a new systemd service file like so:

sudo -e /etc/systemd/system/folding-at-home.service

and paste this code into it.

[Unit]
Description=Folding@Home container
After=docker.service
Wants=network-online.target

[Service]
Restart=always
ExecStartPre=/bin/bash -c "/usr/bin/docker container inspect folding-at-home 2> /dev/null || /usr/bin/docker run -d --name folding-at-home -p 7396:7396 -p 36330:36330 -e USER=Anonymous -e TEAM=0 -e ENABLE_GPU=false -e ENABLE_SMP=true --restart unless-stopped yurinnick/folding-at-home --allow 0/0 --web-allow 0/0"
ExecStart=/usr/bin/docker start -a folding-at-home
ExecStop=/usr/bin/docker stop -t 10 folding-at-home

[Install]
WantedBy=multi-user.target

The ExecStartPre line is simply the command from the last session without the newline escapes, so you can set your username and team by editing the appropriate variables as before.


PSA: the default editor on openSUSE is vi, so unless you are comfortable with vi/Vim or have configured the EDITOR environment variable in your .profile, .bashrc, or similar, pasting can be accomplished like so (sudo nano, sudo vim, etc. is insecure):

  • Press i
  • Paste the code however you normally paste into your terminal
  • Use the arrow keys to navigate to the USER and TEAM variables if you wish to edit them
  • Press <Esc>
  • Press ZZ (make sure those are capital letters)

The service file is written in such a way that it will check if the container exists, then create it if it doesn’t, which means you can simply start it up with no need to run the container manually first. You can now activate the service with

sudo systemctl enable --now folding-at-home.service

That’s it!

What about my GPU?

As I mentioned before, this container is only designed to work with the CPU, but wandhydrant on GitHub has forked Mr. Yurin’s container to make use of your NVIDIA GPU (I was unable to find a version for AMD.) It is somewhat hackier than the original, however, requiring installation of the NVIDIA Container Toolkit—which Tumbleweed users will have to add a Leap repository to obtain—and compiling the container from source, which admittedly is not terribly difficult, but is an extra step.

I would provide you with instructions on setting it up, but I was unable to make it work myself. This may be the result of trying to install Leap packages on Tumbleweed, working with NVIDIA Optimus switchable graphics, or any number of other things, but the bottom line is that it did not work. You are of course welcome to work through wandhydrant’s instructions yourself. If anyone figures this one out, please let me know.


EDIT: I just noticed a mistake in the systemd service file. If anyone has actually read this tutorial in the five minutes it’s been up, you might want to add the ‘u’ to ‘yurinnick’ as well.

3 Likes