Running the FAH client on Linux

From FaHWiki

Jump to: navigation, search

This page is based on The FAH Linux HOWTO.

From FAH (Folding@home) homepage (http://folding.stanford.edu/):

"What does Folding@Home do? Folding@Home is a distributed computing project
which studies protein folding, misfolding, aggregation, and related
diseases. We use novel computational methods and large scale distributed
computing, to simulate timescales thousands to millions of times longer than
previously achieved. This has allowed us to simulate folding for the first
time, and to now direct our approach to examine folding related disease."

Contents

How to run a FAH Client on Linux

Downloading and Installing the Client

Before You could run a FAH client, You must download it:
http://folding.stanford.edu/English/Download

Currently there is only a Console Client for Linux (latest versions are 6.02/6.24beta):
http://www.stanford.edu/group/pandegroup/folding/release/FAH6.02-Linux.tgz
http://www.stanford.edu/group/pandegroup/folding/release/FAH6.24beta-Linux.tgz



1) Download this FAH client and place it to a separate folder as this client will create a set of files and folders when it is started;
2) After successfully retrieving the client set the binary as executable; Note: All examples in this document must be run at command prompt (such as console/konsole/xterm/...).

Example:

mkdir /folding
cd /folding
wget http://www.stanford.edu/group/pandegroup/release/FAH504-Linux.exe
chmod +x FAH504-Linux.exe

or

mkdir /folding
cd /folding
curl -O http://www.stanford.edu/group/pandegroup/release/FAH504-Linux.exe
chmod +x FAH504-Linux.exe


NOTE: When upgrading the FAH client then delete old FAH4Console-Linux.exe before getting new one with "wget"/"curl".
Check the binary with md5sum/md5 to verify You have unmodified binary. Correct md5sum values for FAH clients are available at http://www.stanford.edu/group/pandegroup/folding/download.html.

Example:

md5sum FAH504-Linux.exe

In case of FAH client version 5.04, You should get:

1316853b439d25a4a56adf82fcd953db  FAH504-Linux.exe

Read First

Note: The FAH binary MUST be located in the Current Working Directory ($CWD) to work properly!
BAD EXAMPLE - NEVER USE IT:

/home/user:$ /folding/FAH504-Linux.exe

GOOD EXAMPLE:

cd /folding && ./FAH504-Linux.exe

ANOTHER GOOD EXAMPLE:

# cd /folding
# /folding/FAH504-Linux.exe


**** Important: Read the FAH license! ****
To read the license run:

cd /folding
./FAH504-Linux.exe -license | less

Running the Client Manually

The easiest way to run the FAH client is to fire up a console, change to FAH dedicated folder You created and run a FAH executable.

Example:

cd /folding
./FAH504-Linux.exe

First time You run FAH client it will ask You a couple of configuration parameters:

User name [Anonymous]?
Team Number[0]?
Ask before fetching/sending work [no]?
Use proxy [no]?
Allow receipt of work assignments and return of work results greater than
 5MB in size (such work units may have large memory demands) (no/yes) [no]?
Change advanced options [no] (yes/no)? 

Note: To change the configuration later, You must run the client with -config (or -configonly) switch:

cd /folding
./FAH504-Linux.exe -config

After the configuration client should fetch a Work Unit (WU), proper Core for it and start counting finished frames:

[17:41:13] Finished a frame (75)
[17:42:43] Finished a frame (76)
[17:44:14] Finished a frame (77)

To stop the client press CTRL+C.

B) To get the FAH Linux Console client run as background service.

Q: Why to run FAH as a service?
A: Service by definition will run on background and will be started when You boot up Your machine and will be "killed" when You turn off the box. It is the most effective way to increase the productivity of the FAH client and all the rest what will come out of it.

I) After previous steps (download and manual run) add couple lines of code to the end of rc.local (/etc/rc.d/rc.local) file:

cd /folding
./FAH504-Linux.exe >/dev/null &


Note: This script will run FAH under root privileges as rc.local file will be run under root privileges (all created files/folders will be under root privileges, too). To overcome this and to run FAH as regular user (RegularUser must be set to one of user who is present on this system):

su - RegularUser -c "cd /folding; ./FAH504-Linux.exe >/dev/null &"

If You ran first-time-run as root or as some other user than RegularUser then You must change FAH folder privileges:

su -
chown -R RegularUser.RegularUserGroup /folding


Only bad thing is that there is no easy (as easy as pressing [CRTL+C]) way to stop this client anymore.
As FAH will start up several processes then there is nothing else to do than hunt down and kill these processes. To make our life a little easier FAH client will die if the running cores die (should be a rule but not always...):

cd /folding
kill -15 $(ps -C $(ls *Core_*.exe) -o pid=)

Note: This is a "polite" termination (waiting FAH client and cores to finish their job) and if ps -ax should still show some cores running (newer cores may have this bug) then use a forced termination (no more waiting...):

cd /folding
kill -9 $(ps -C $(ls *Core_*.exe) -o pid=)

Attention! As FAH and Core different versions tend to respond differently to "killing" of these then it may be advisable to issue the same kind of "kill routines" to FAH client itself, too:

killall -15 FAH504-Linux.exe

and if it is still not dead (check it with "/sbin/pidof FAH504-Linux.exe") then:

killall -9 FAH504-Linux.exe

( Folding-community: Question about NFS and cron )

Note: To get a FAH client to run on multi cpu machine, You must install as many FAH clients to separate directories as there are processors in Your machine and You may need to configure Your clients to use different Machine IDs (look to "Configuring the client").
Note: Never copy FAH files between separate clients as the usual outcome is more often bad than good.

Running via screen

Another way to run FAH Client as service is to use 'screen' utility:
Folding-community: Running on a server

Usage:

1) Fire up 'screen';
2) Start FAH Client:

cd /folding
./FAH504-Linux.exe

3) If You want to leave this console/session and let the FAH run press CTRL+a+CTRL+d or run 'screen -d' on this computer (from another console/session);
4) To regain the FAH session run 'screen -r' (if You have multiple screen utilities running then You must specify it).;
5) Goto 3;

Or, if you want to use screen to automatically launch folding @ home, add

cd /folding
sudo -u <YourUsername> screen -d -m ./FAH504-Linux.exe

To rc.local, as above, which will start a screen session as YourUsername in the background so you can use screen -r then control-C to shut it down.

Running as an Init Script

Yet another way to run the Linux Folding @ Home client is through init scripts. This will allow Folding @ Home to run as a daemon in the background at system startup.

NOTE: You will need to have configured the client before using this init script. You can configure the client by running the following command

cd /folding
./FAH502-Linux.exe -config

This init script was made for Ubuntu, but will probably work on most Debian-based distributions.

#!/bin/sh
#
# $Id: folding.init.d,v 1.2 2008/02/27 13:20:31 est Exp $
#

### BEGIN INIT INFO
# Provides:          folding
# Should-Start:      $local_fs,$network
# Should-Stop:       $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Folding @ Home Client
# Description:       Folding @ Home Client
### END INIT INFO

#Adapted from dhcp3-server init file

PATH=/sbin:/bin:/usr/sbin:/usr/bin

test -f $DAEMON || exit 0

. /lib/lsb/init-functions

#Configure these variables to suit your needs

MYUSER='myself'				#Run as this user (Change this!)
WORKING='/home/myself/folding/' 	#Process Working Directory (This is where the FAH client is stored)
NAME='FAH504-Linux.exe'			#Process Name	  (This is the Folding @ Home executable name)

#No need to edit below this line

DESC='Folding @ Home Client'		#Process Description	   (Brief line to describe FAH)
DAEMON="$WORKING$NAME"			#Full Path to the Daemon
MYPID="/var/run/$NAME.pid"		#PID file

# single arg is -v for messages, -q for none
check_status()
{
	if [ ! -r "$MYPID" ]; then
		test "$1" != -v || echo "$NAME is not running."
		return 3
	fi
	if read pid < "$MYPID" && ps -p "$pid" > /dev/null 2>&1; then
		test "$1" != -v || echo "$NAME is running."
		return 0
	else
		test "$1" != -v || echo "$NAME is not running but $MYPID exists."
		return 1
	fi
}

case "$1" in
	start)

		log_daemon_msg "Starting $DESC" "$NAME"
		if start-stop-daemon -b -m --start --chdir "$WORKING" --chuid "$MYUSER" --quiet --pidfile $MYPID \
			--exec "$DAEMON"; then
			log_end_msg 0
		else
			log_end_msg 1
			exit 1
		fi
		;;
	stop)
		log_daemon_msg "Stopping $DESC" "$NAME"
		start-stop-daemon --stop --quiet --pidfile $MYPID
		log_end_msg $?
		rm -f "$MYPID"
		;;
	restart | force-reload)
		test_config
		$0 stop
		sleep 2
		$0 start
		if [ "$?" != "0" ]; then
			exit 1
		fi
		;;
	status)
		echo -n "Status of $DESC: "
		check_status -v
		exit "$?"
		;;
	*)
		echo "Usage: $0 {start|stop|restart|force-reload|status}"
		exit 1 
esac

exit 0


Copy and paste the above script into a file named 'folding' in your home folder, then run the following commands. These commands set ownership to root, give the script execute permissions, and drops it in your /etc/init.d folder.

cd ~
chmod +x folding
sudo chown root:root folding
sudo mv folding /etc/init.d/

To enable the folding client to run at startup, use the following command to add it to the startup sequence.

chkconfig --level 2345 folding on                     # RedHat based distros
update-rc.d folding defaults                          # Debian based distros
sudo ln -s /etc/init.d/folding /etc/rc3.d/S99folding  # Manual

Official information:
http://folding.stanford.edu/linux.html
http://folding.stanford.edu/console-userguide.txt

Personal tools