Snapping Folding@Home, distributed computing for research on diseases

Hi, I recently tried to install Folding at Home on my Ubuntu 20.04 laptop. Unfortunately a dependency is missing for FAHControl to work, python-gnome2.

Hence I was thinking that it would be awesome if we could package FAHClient, FAHViewer, and FAHControl into a snap based on the 18.04 stack.

Just I’m not sure if it’s possible to do so from a machine with 20.04, is it?

P.S: I’m not sure if the FAHClient is actually open source and even redistributable…

Update
You can try and test the snap:
Get it from the Snap Store
Please, try the channel edge:
snap install folding-at-home-fcole90 --edge
snap connect folding-at-home-fcole90:hardware-observe

Report issues on:

You can interact with FAHClient as a service, as described here: https://snapcraft.io/docs/service-management

E.g.

snap services folding-at-home-fcole90.FAHClient 
Service                            Startup  Current  Notes
folding-at-home-fcole90.FAHClient  enabled  active   -

Not related to the snap, but I managed to install the FAHControl on Focal: https://github.com/fcole90/fah-control/releases/tag/7.5.1-1_focal_1

Random aside: I set up a team on Folding@Home for the Ubuntu Podcast. It is team number 243272 if you’d like to join us :slight_smile:

1 Like

I started snapping those applications, but could only succeed using classic confinement.
See also

2 Likes

Awesome job! I’ll try it and let you know! :smiley:

What errors do you get in confined mode? :blush:

I see that you referenced a GTK2 tutorial, but in your code you are not using the suggested plugs, which likely the first reason for why it is not working when confined :blush:

However it might indeed be necessary to ask classic confinement for what concernes OpenCL, or at least ask suggestions :thinking:

@ogra @mborzecki I found an old discussion where you were discussing how to handle the OpenCL issue. Is there any new and improved way to do this today? :slight_smile:

well. looking at the opengl interface i see:

# OpenCL ICD files
/etc/OpenCL/vendors/ r,
/etc/OpenCL/vendors/** r,

and trying it out with an app that uses opengl:

$ snap run --shell trigger-rally-ogra
$ cat /etc/OpenCL/vendors/nvidia.icd 
libnvidia-opencl.so.1
$ ls /var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1
/var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1

so if /var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/ is in your LD_LIBRARY_PATH it might actually work … (not sure if this is actually enough though, the lib might need additional device access that isnt covered in opengl yet)

1 Like

Thanks a lot, we can start from this and then do some trial and error :blush: :+1:

1 Like

I added some new rules based on the GTK2 tutorial: https://github.com/fcole90/FAH-snap

You can now try it with snap install folding-at-home-fcole90 --edge.
Online at https://snapcraft.io/folding-at-home-fcole90
I didn’t want to register it with the plain name so I can later ask FAH if they want to.

What works (at least partially):

  • FAHControl, the interface, loads correctly and can be launched with its desktop file.
  • FAHClient is loaded as simple daemon, so that FAHControl can connect to it. I got a fold job and it started folding on the CPU
  • FAHWebClient: you can launch it on http://client.foldingathome.org/ and control the client.

What doesn’t work:

  • Sometimes FAHClient starts computing, for no apparent reason. I think it might have something with the restart-condition: on-failure but I’m not sure.
  • The client cannot detect OpenCL
Not detected: Failed to open dynamic library 'libOpenCL.so': libOpenCL.so: cannot open shared object file: No such file or directory

but I can find the OpenCL file @ogra mentioned

snap run --shell folding-at-home-fcole90.FAHClient
fabio@fabio-X550JK:/home/fabio/scratch/folding-at-home$ cat /etc/OpenCL/vendors/nvidia.icd 
libnvidia-opencl.so.1

This makes me think that it’s missing some symlink… :thinking:

  • FAHControl logs a lot of errors for checking the battery:
Failed to open '/sys/class/power_supply/AC0/online': Permission denied: iostream error: Permission denied

I added the upower-observe plug, but it doesn’t change the outcome.

What I didn’t test:

  • FAHViewer

The source is available at https://github.com/fcole90/fah-snap and is forked from the inital work done by @thymythos . I couldn’t make it without it, thanks again.

Now also FAHViewer is working.
If you can, test and let me know :smiley:

Get it from the Snap Store

this seems to look for an unversioned libOpenCL.so … but the ocl-icd-libopencl1 you ship in stage-packages only provides libOpenCL.so.1 and libOpenCL.so.1.0.0 … i guess just adding an additional symlink (from an override-prime: directive) so that libOpenCL.so points to libOpenCL.so.1 in usr/lib/$SNAPCRAFT_ARCH_TRIPLET might be enough …

i’d try hardware-observe though i dont see /sys/class in there (it has /run/udev/data/+power_supply:* r,), this might be a bug

Thank you very much for your precious help. I added the following to the client:

    override-prime: |
      snapcraftctl prime
      ln -s $SNAPCRAFT_PART_INSTALL/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libOpenCL.so.1 $SNAPCRAFT_PART_INSTALL/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libOpenCL.so

But it’s still not detected. The snap with this change is currently in edge if you want to check.

I added this too, but with no luck.

you want to set the link in the prime/ dir, so use $SNAPCRAFT_PRIME instead of $SNAPCRAFT_PART_INSTALL everywhere in that line …

Should it be like this?

override-prime: |
      snapcraftctl prime
      ln -s $SNAPCRAFT_PRIME/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libOpenCL.so.1 $SNAPCRAFT_PRIME/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libOpenCL.so

I built it from the launchpad service but I couldn’t release it because of the following error:
Error:package contains external symlinks: usr/lib/x86_64-linux-gnu/libOpenCL.so :thinking:
It looks like the $SNAPCRAFT_PRIME variable was empty :thinking:

https://build.snapcraft.io/user/fcole90/fah-snap/882499

I am now trying to build locally…