Snapping Folding@Home, distributed computing for research on diseases

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? :relaxed:

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…

hmm, during the prime step you are actually in the prime/ folder so that is probably why the variable is not set … just make it a relative path:

ln -s usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libOpenCL.so.1 usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libOpenCL.so

I’m sorry, it’s still not working. I went into the snap shell and I run FAHClient --lspci, which returns

09:04:44:ERROR:Exception: Failed to open '/sys/class/power_supply/AC0/online': Failed to open '/sys/class/power_supply/AC0/online': Permission denied: iostream error: Permission denied
09:04:44:WARNING:Exception: Failed to open '/proc/bus/pci/devices': Failed to open '/proc/bus/pci/devices': Permission denied: iostream error: Permission denied
VendorID:DeviceID:PCI Bus:PCI Slot:PCI function:Vendor Name:Description

I’m now thinking that it may not even be looking for the libOpenCL object, but rather for the GPU first, which it can’t detect :thinking:

Edit: I had to manually connect hardware-observe. Now the I get the following:

VendorID:DeviceID:PCI Bus:PCI Slot:PCI function:Vendor Name:Description
0x8086:0x0c04:0:0:0:Intel Corporation:
0x8086:0x0c01:0:1:0:Intel Corporation:
0x8086:0x0416:0:2:0:Intel Corporation:
0x8086:0x0c0c:0:3:0:Intel Corporation:
0x8086:0x8c31:0:20:0:Intel Corporation:
0x8086:0x8c3a:0:22:0:Intel Corporation:
0x8086:0x8c20:0:27:0:Intel Corporation:
0x8086:0x8c10:0:28:0:Intel Corporation:
0x8086:0x8c14:0:28:2:Intel Corporation:
0x8086:0x8c16:0:28:3:Intel Corporation:
0x8086:0x8c49:0:31:0:Intel Corporation:
0x8086:0x8c03:0:31:2:Intel Corporation:
0x8086:0x8c22:0:31:3:Intel Corporation:
0x10de:0x1391:1:0:0:NVIDIA Corporation:
0x168c:0x0036:3:0:0:Qualcomm Atheros:
0x10ec:0x5287:4:0:0:Realtek Semiconductor Co., Ltd.:
0x10ec:0x8168:4:0:1:Realtek Semiconductor Co., Ltd.:

Still it complains of missing libOpenCL…

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`

When I tried before, I didn’t notice that I had to manually connect the plug. It actually worked! :smile: Thanks! :pray: :+1: