[How-To] FreeNAS CPU Idle? Donate them to Science! Folding @ home

icsy7867

Contributor
Joined
Dec 31, 2015
Messages
167
There are a few services and developers who have cool things like this, but I am specifically going to be going through Folding at home. You can read about it here:
https://folding.stanford.edu/

(You can also help the search for intelligent life in outspace! https://setiathome.berkeley.edu)

To begin, you will a virtual machine. Make sure to only give it as many CPU cores (Or in reality, threads...) that you would like to donate. I wanted to stick to what I knew, so I am running a dual core CentOS minimal BHYVE VM with a 25GB HDD, and 2GB of RAM (You could probably get away with less). I will not go into the process of setting up a VM in Freenas, but if someone needs help it is pretty easy and I don't mind helping. I prefer CentOS or RH over Ubuntu, and I recommend using the minimal ISO:
http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso

*Note* When choosing your VM Core count, these will be 100% in use by the FAHClient for folding. Use this to limit how much of your total CPU the FAHClient has access to!

After your VM is installed make sure that it is fully updated:

sudo yum update -y
sudo yum install wget


I also prefer Nano (or use vi/vim). Use this to check your config.xml files below if you wish
sudo yum install nano

also enable SSH and start it on boot. This will be a lot easy from putty or an ssh client.
sudo systemctl start sshd.service
sudo systemctl enable sshd.service

Once you are fully updated and SSH is enabled, I would recommend switching to an SSH client for easy copy/paste operations.
Installation for the FAHClient can be found on there website:
http://folding.stanford.edu/support/faq/installation-guides/linux/manual-installation-advanced/

Download and install Instructions:
wget --no-check-certificate https://fah.stanford.edu/file-releases/public/release/fahclient/centos-5.3-64bit/v7.4/fahclient-7.4.4-1.x86_64.rpm
wget --no-check-certificate https://fah.stanford.edu/file-releases/public/release/fahcontrol/centos-5.3-64bit/v7.4/fahcontrol-7.4.4-1.noarch.rpm
wget --no-check-certificate https://fah.stanford.edu/file-releases/public/release/fahviewer/centos-5.3-64bit/v7.4/fahviewer-7.4.4-1.x86_64.rpm

Install the FAHClient.

sudo rpm -i --nodeps fahclient-7.4.4-1.x86_64.rpm

Install the FAHControl application. Root privileges are required.

su -c 'rpm -i --nodeps fahcontrol-7.4.4-1.noarch.rpm'

Optionally, install the FAHViewer. (I dont think this is helpful in a terminal only environment...)

su -c 'rpm -i --nodeps fahviewer-7.4.4-1.x86_64.rpm'

Once these are installed we need to set everything up. First let's generate a username and passkey:
http://fah-web.stanford.edu/cgi-bin/getpasskey.py
You can stay anonymous if you like, but that's less fun...

You will get a username, and a passkey that you will use for configuration. You will get an email with this information.

You will then need to run the fahclient configuration wizard to generate a config.xml:

sudo /usr/bin/FAHClient --configure This will have a bunch of prompts that are pretty self explanatory.
*Optional* Join the FreeNAS team! When the second prompt asks you for a team number, use 234067
After entering your username, team name, and passkey, you can pretty much leave everything default. I set the GPU option to False, but if you leave enabled and you have no GPU, it should automatically detect that. Also if you dont use SUDO, the program wont have permissions to write the file, but it wont tell you this.

Once this is done, we need to copy over this generated config.xml to the proper location.
You should see it with the name you gave it from the configuration tool
cd /var/lib/fahclient/configs

Copy this config that you found to the proper location (You will need to strip out the timestamp information).
sudo cp config-Yourtimestamp.xml /etc/fahclient/config.xml

And that should do it! Run the fahclient service in verbose mode to make sure that it picked up your information.
sudo /etc/init.d/FAHClient start -v

The "-v" will be verbose and show you the settings that your FAHClient are running. Ensure that it picked up your username and team name!
 
Last edited:

Nick2253

Wizard
Joined
Apr 21, 2014
Messages
1,633
I'm confused a bit by this setup. I personally run an idle CPU process like Folding@Home on my home desktop, but it's exactly that: an Idle CPU process. How does this setup adjust for CPU usage? My home NAS sits idle pretty regularly, but I fail to see how FAH in this setup would be aware of when I actually need the CPU (lots of downloads, or running a Plex stream, for example).

Is there some magic throttling setting that needs to be set in bhyve that is not mentioned here? Or is this setup just giving FAH free reign at all times?
 

icsy7867

Contributor
Joined
Dec 31, 2015
Messages
167
So, the above setup is limited by the nature of how VM's handle CPU threads. If you read above, I only gave my CentOS Virtual Machine on FreeNAS 2 virtual CPUs. My process is a Xeon-D 1528, which has 6 cores and is hyper threaded, so I have 12 available threads. By giving the VM only 2 threads, my FreeNAS Box will have the other 10/12 threads free which is more than enough for me and my emby transcodes. I can barely tell it is even running.

You can also limit threads/CPUs using the config or command line. So if you have 4 threads, you can limit the FAHClient to only 1 thread, so it does not take away everything else. I believe there is also ways to reduce the threshold so that it will only use a certain percent of a single processor, but I have not played around with that to be honest.
 
Last edited by a moderator:

Nick2253

Wizard
Joined
Apr 21, 2014
Messages
1,633
Ahh, that's too bad. I was hoping there was some secret sauce here that I was missing.
 

MikeyG_U2

Cadet
Joined
Apr 10, 2018
Messages
1
Ahh, that's too bad. I was hoping there was some secret sauce here that I was missing.

Sorry to revive a 6-week old thread. I run Folding@Home (FAH) quite a bit on several machines and am just building my first FreeNAS and came across this as I seek info.

As for the secret sauce, by default FAH will run with a high nice-value (low process priority), so it will use all CPU cycles not being used by processes with a higher priority. So when a system is idle it will use all the cpu, when you are doing something that needs CPU, it will scale back. For Example: If you have a video transcode running in Plex Media Server that consumes 50% of your CPU capacity, Plex will get what it needs, and FAH will use the remaining 50%. In essence your CPU runs at 100% all the time but with FAH yielding to other processes. That's how it would work if FAH was installed as a native app on the host OS.

In the example given by icsy7867 above, it will only ever consume up to 2 CPU threads on the entire system because the VM has a max of 2 CPU threads assigned to it and that is all FAH sees as available from inside its VM (which is essentially a 2-core VM), but it will use 100% of those 2-cores (threads) available to the VM. I hope that makes sense, that last sentence reads a little bit like "60% of the time it works, every time".

If icsy7867's machine always has at least 2 thread's worth of available CPU capacity, this will be fine. However because FAH is isolated inside another VM, it will not be aware of other processes on the FreeNAS OS that are trying to use CPU, and if icsy7867 tries to run something that would need all 12 of the CPU threads (like many simultaneous Plex transcodes), there may be some contention unless there is priority set at the BHYVE level to give guest VM's lower priority than the host OS. I know that VMWare ESXi allows prioritization, but I'm not yet familiar with BHYVE.
 

alwu

Dabbler
Joined
Jan 24, 2018
Messages
36
folding@home added covid-19 projects recently, so i tried installing this on 11.2-u8. the instructions are still good. thanks! a few minor things changed.

the urls for linux rpms are different now. also, the installation instructions on the folding@home site say to use sudo commands to install the rpm files.

the config.xml generated by FAHClient --configure is what should get copied to /etc/fahclient. the timestamped config xml files in /var/lib/fahclient/configs are backups of previous configs.
 

greinbold

Dabbler
Joined
Apr 6, 2019
Messages
12
folding@home added covid-19 projects recently, so i tried installing this on 11.2-u8. the instructions are still good. thanks! a few minor things changed.

the urls for linux rpms are different now. also, the installation instructions on the folding@home site say to use sudo commands to install the rpm files.

the config.xml generated by FAHClient --configure is what should get copied to /etc/fahclient. the timestamped config xml files in /var/lib/fahclient/configs are backups of previous configs.

Also, there is a little script to install FaH on FreeBSD: https://github.com/mrclksr/fah-installer
 
Top