Fight Covid-19 with Folding@home and NixOS

One thing that I didn’t know is that only GPU is contributing towards corona research. So if you are contributing only CPU, it won’t help with this project specifically. Sorry, my initial message wasn’t precise enough and misleading.

I found this repo that has more information on the subject:

3 Likes

That was not the case until NixOS 20.03 release, was it ? Using nixpkgs=channel:nixos-19.09-small (New constraint between Release 19.09 and 20.03 in package qemu?) qemu just worked.

It seems that the Rosetta@Home (part of BOINC) is also helping to fight COVID-19, and in that case CPU-only users can also contribute. It’s quite easy to use in NixOS as BOINC Manager is already packaged in nixpkgs.

For me, using the services.boinc.enable option was not enough, and I had to manually launch the client boinc_client, and then configure it using boincmgr.

I’ve seen a few tasks labeled COVID-19 go through.

4 Likes

Latest stats. 319 CPUs running! That’s pretty impressive.

Packet.com have donated 100 m1-xlarge instances for the project thanks to @grahamc’s involvement.

image

5 Likes

Just out of curiosity, what is the AMD GPU situation? I got the impression it would only work for Nvidia but looks like there is an opencl-mesa implementation that works with the AMDGPU driver. Will that all work with the latest version of the package in nixpkgs?

Warning for those trying this method: the client stores some data in $PWD/work (including the work units and some configuration I think), so I’d suggest creating some permanent directory just for Folding@home and always cding to it before running the client, both to make sure you don’t lose work units in random places in your disk, and also to avoid cluttering up whatever directory you happened to be in.

1 Like

This is how I got F@H running on my GeForce GTX 1080 Ti server running NixOS 19.03 (actually it was mostly @Infinisil):

{ config, lib, pkgs, ... }:
let
  pkgs_latest = import <nixpkgs_latest> { inherit (config.nixpkgs) config; };
in
{
  disabledModules = [
    "services/misc/folding-at-home.nix"
  ];

  imports = [ 
    <nixpkgs_latest/nixos/modules/services/computing/foldingathome/client.nix>
  ];

  services.foldingathome.enable = true;
  services.foldingathome.package = pkgs_latest.fahclient;

  # From https://github.com/lovesegfault/nix-config/blob/8dd6eedd08cebaf39dd70203ff9e51f4c14cb8ec/hardware/nvidia.nix
  systemd.services.nvidia-control-devices = {
    wantedBy = [ "multi-user.target" ];
    serviceConfig.ExecStart = "${config.boot.kernelPackages.nvidia_x11.bin}/bin/nvidia-smi";
  };

  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.opengl.enable = true;
}

Additionally, since F@H is regularly running of ouf work with such a surge of new donors in last days, I also installed rosetta@home that still has pending covid-19 related CPU work, by adding:

  services.boinc.enable = true;
  services.boinc.allowRemoteGuiRpc = true;

And then installing BOINC Manager locally on my laptop and connecting to it via SSH tunnel on port 31416. The connection password is stored in /var/lib/boinc/gui_rpc_auth.cfg .

Finally I created a NixOS team for rosetta too: NixOS (I’ll gladly defer administration of the team to a more senior nixos person)

I’ve had no luck completing GPU Work Units, the Status tab is properly detecting my GPU Slot (gpu:0:Hawaii [Radeon R9 200/300 Series]) but the System Info tab is showing OpenCL: Not detected: clGetPlatformIDs() returned -1001, plus such error logs are showing up when a WU is given to me: 14:48:38:ERROR:WU02:FS00:Failed to start core: OpenCL device matching slot 0 not found, try setting 'opencl-index' manually. I have set opencl-index to 1 but I will need to wait another WU to figure out if it works out.
Would love to hear how people got it working.

For an AMD RX580, I used the nixos-rocm overlay on nixos-unstable. Github page on nixos-rocm also covers most of this. Another solution I tried which did not work was attempting to install amdgpu-pro.

git clone https://github.com/nixos-rocm/nixos-rocm.git /etc/nixos/overlays/

in /etc/nixos/configuration.nix

nixpkgs.overlays = [ (import ./overlays/nixos-rocm)];
 
hardware.opengl = {
  enable = true;
  extraPackages = with pkgs; [
    rocm-opencl-icd
    rocminfo
    rocm-opencl-runtime
    rocr-ext
  ];
};

I also had to specify usage of gpu slot 1 in folding@home configuration, f@h did not auto-find it.

4 Likes

If anyone is running into issues getting assigned jobs, the Work Servers running out of jobs due to the spike in the number of F@H clients.
It seems the team is working on it.
https://foldingforum.org/viewtopic.php?f=24&t=32424

I created a PR that improves services.boinc so it should be easier to use.

After applying this PR every user that is member of the boinc group can configure the BOINC service via boincmgr -d /var/lib/boinc.

Let me know if this helps.

4 Likes

It’s me or there’s some projects using the CPU for covid now?

1 Like

Hmm right, I forgot to revert the statement on the post. Apparently there are some CPU projects as well.

@zimbatm Does the client need to be updated?

In response to popular demand, we have created an update to the Folding@home software that allows you to prioritize COVID-19 projects. We encourage you to upgrade as the new software includes important bug fixes and security updates. Downloads are available here. Please also join me in thanking the Center for the Science and Engineering of Living Systems (CSELS) at Washington University in St. Louis for funding the development of this software update.

EDIT: my bad, nixpkgs already has the new version, I was still using https://github.com/zimbatm/nixpkgs/archive/foldingathome.tar.gz.

thanks to @evils for updating the package <3

2 Likes

i updated it in hopes of getting remote control (connecting FAHControl to a remote FAHClient) working
it didn’t help, i still suspect this is an issue with FAHClient, has anyone been able to do this?

though with summer on the way and my old 5870’s lacking driver support, i’m in no hurry to get that working

It’s weird. My gpu is not detected and even if I have

services.xserver.videoDrivers = [ "nvidia" ];

in my config.

I’m pretty sure it used to work. I stopped running the program during a heat wave and I wanted to run it again.

EDIT: oh it might be fine now. Maybe it has something to do with the 22:35:19:Updated GPUs.txtline in the log.

I realise this thread is old, but it seems to be the only one on this topic, so hopefully I’ve come to the right place.
I’ve been trying to fah working consistently and failed miserably with the GPU side…

For AMD (6900XT) I use this configuration.nix elements:

hardware.opengl = {
enable = true;
driSupport32Bit = true;
extraPackages32 = with pkgs.pkgsi686Linux; [ libva ];
setLdLibraryPath = true;
extraPackages = with pkgs; [
rocm-opencl-icd
rocm-opencl-runtime
rocm-runtime
amdvlk
];
};

and (in summary) services.foldingathome.enable = true;

I do similar for Nvidia (1070Ti) - I need to review that and can add later.

The AMD fails with bad work units, being unable to find OpenCL (although it finds it on startup). The Nvidia failed after an update :frowning: All CPU elements work fine.

My main issue is how to debug - any suggestions?

Many thx

2 Likes

An update to my last post - with what appears to be a working solution!

I have an updated opengl config - see below. On its own, this does not make a difference to FAH, so you may not need all these depending on your other needs.

hardware.opengl = {
enable = true;
driSupport = true;
setLdLibraryPath = true;
extraPackages = with pkgs; [
rocm-opencl-icd
rocm-opencl-runtime
amdvlk
vaapiVdpau
libvdpau-va-gl
];
};

A key addition is the following package - mine is in the nix configuration as I run FAH as a service:

environment.systemPackages.ocl-icd (OpenCL ICD Loader for opencl-headers)

The above package is in the source, so I am not sure why it needs to be added explicitly!

This is still not quite enough - the last step is to amend the fahclient config.

The easiest way is to use the fahcontrol configure option and add these under the expert tab:

gpu-beta=true
opencl-index=0 (my GPU is pci bus 12, pci slot 0 which is why I think you set this to 0)

In config.xml it would be:

I have also played with
services.xmr-stak.openclSupport = true;

but I don’t think this is needed (noted here as it may help you with older AMD cards).

Hope this may be of help to folders out there…

1 Like

Sadly replying to my own post - the initial post is not necessarily a solution!

Having rebuilt my machines using the extant configuration.nix, I no longer have a folding GPU (back to my original error).

So I have either:

  1. Changed something in the config I’ve not noted (unlikely)
  2. There is something beyond the system config (for example I didn’t back up my /home) needed to make this work.
  3. The rebuild led to a newer version of the system which has broken something.

Does anyone have a working approach? Please share :slight_smile: :slight_smile:

1 Like