FoldingAtHome

Differences between revisions 1 and 25 (spanning 24 versions)
Revision 1 as of 2005-10-09 20:48:38
Size: 8464
Editor: 70-57-196-186
Comment:
Revision 25 as of 2006-05-07 21:06:31
Size: 6740
Editor: 70-57-193-50
Comment: lots of little changes
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
Folding@Home is a great way to make your computer do useful work even when you're not using it. Since it runs at a very low priority, you should never realize it's running when you're using the computer to do your work. Note that "using the computer" refers to doing heavy computations. Generally, tasks like web browsing and word processing involve very little CPU usage, so the Folding@Home client will be running at near 100% even when doing those kinds of tasks. Folding@Home is a great way to make your computer do useful work even when you're not using it. Since it runs at a very low priority, you should never realize it's running when you're using the computer to do your work. Note that "using the computer" refers to doing heavy computations. Generally, tasks like web browsing and word processing involve very little CPU usage, so the Folding@Home client will be running at near 100% even when doing those kinds of tasks.  It helps to leave you computer on at all times, but is not necessary, as the project will benefit from virtually any time that the client runs on your computer.
Line 9: Line 9:
The following script will download the latest client from the Folding@Home website, and install it to /opt/foldingathome. It will ask you to set up the client (the defaults are usually sufficient), and copy that configuration for every CPU in your machine. The following script will download the latest client from the Folding@Home website, and install it to {{{opt/foldingathome}}}, either in {{{/}}} or {{{$HOME}}}. It will ask you to set up the client (the defaults are usually sufficient), and copy that configuration for every CPU in your machine.

 *attachment:fah_install-20060421.tar.gz
Line 13: Line 15:
Download these scripts to the same directory, and name them folding_install.sh and foldingathome, respectively. Then do To install, download the tarball and do
Line 15: Line 17:
chmod 500 foldingathome folding_install tar zxvf fah_install-version.tar.gz
Line 17: Line 19:
to make them executable. Finally, do This should extract the archive to a directory called {{{fah_install/}}}. Then
Line 19: Line 21:
sudo ./folding_install.sh cd fah_install
less README
}}}
to read the documentation.
Finally,
{{{
sudo ./folding_install.sh install
Line 23: Line 31:
=== Install Script === You can also install to your {{{$HOME}}}, in case you do not have root access to the computer. Clearly, you would not have to prefix the command with sudo in this case. If you install to your {{{$HOME}}}, a cron job will be created to start the client automatically. If you install to the system, the client will automatically start when your computer boots up.

You can reconfigure the client using the supplied {{{reconfigure}}} script, which is placed in {{{opt/foldingathome}}}. You can also give the client command line options. See the README for more details.

=== Laptop Systems ===
Because the client runs at low priority, the client should not cause the CPU governor to kick up the frequency. In other words, even though the client runs at 100% CPU usage, it should not cause the CPU frequency to go up, which keeps the fan slow and quiet. If this is not the case, then the frequency governor should be reconfigured.

One can configure ACPI (the power regulation subsystem) to stop the client when the system goes on battery power, and to start it again when the power cord is plugged back in. Edit {{{/etc/acpi/power.sh}}}. Inside the {{{if [ $? = 0 ] && [ x$1 != xstop ]; then}}} block, add
Line 25: Line 40:
#!/bin/sh     # stop folding at home
    if [[ -x /etc/init.d/foldingathome ]] ; then
        /etc/init.d/foldingathome stop
    fi
}}}
and inside the {{{else}}} block, add
{{{
    if [[ -x /etc/init.d/foldingathome ]] ; then
        /etc/init.d/foldingathome start
    fi
}}}
This assumes that the client has been installed for the entire system, which it should be if you are able to edit files in {{{/etc}}} in the first place!
Line 27: Line 53:
# to do:
# add foldingathome user
# no password, shell /bin/true, only has access to fah_dir
# add option of running from $HOME
# uninstall
== Other Issues ==
For questions and bug reports, go to the [http://ubuntuforums.org/showthread.php?t=101817 HowTo forum thread]. For casual talk about Folding@Home, use the [http://ubuntuforums.org/showthread.php?t=102313 Team Recuiting thread].
Line 33: Line 56:
fah_dir=/opt/foldingathome
this_dir=$PWD
#fah_dir=$HOME/opt/foldingathome
config_dir=$fah_dir/config
executable=FAH502-Linux.exe
=== Security ===
Folding@Home is secure. The Stanford team has gone to great lengths to ensure security, both for the integrity of their research and the safety of donors' computers. However, the more secure the better. The Gentoo ebuild for Folding@Home creates a new user foldingathome whose sole purpose is to run the client. Now this installer offers same. It creates a user whose account is disabled, and runs the client as this user when the init script is run as root, so the client is never run as root.
Line 39: Line 59:
# check if installed
if [[ ! -d $fah_dir || ! -d $config_dir || ! -x $config_dir/$executable ]] ; then
    echo
    echo "Creating directory structure..."
    
    test -d $fah_dir || /bin/mkdir $fah_dir
    test -d $config_dir || /bin/mkdir $config_dir
    cd $config_dir
    
    echo
    echo "It appears that you have not installed Folding@Home yet. Would you like me to download it for you?"
    select resp in {yes,no} ; do
        if [[ $resp == "yes" ]] ; then
            if ! wget http://www.stanford.edu/group/pandegroup/release/$executable ; then
                echo "Downloading Folding@Home failed."
                exit 1
            else
                /bin/chmod 555 $executable
            fi
        else
     echo
     echo "Please download the executable and save it to $config_dir."
     echo "Then re-run this script."
     exit 1
 fi
        break
    done
fi
=== Hyper Threading ===
For those with Hyper Threading CPUs, you probably know that an SMP kernel sees two processors. Then clearly, if you run two clients, you will get more work done than if you only run one (probably about 10-30% more). However, results that are done quickly are more useful than more results done slowly. The reason is that each work unit is a step in a giant simulation, with future steps depending on past ones. So the faster you get your work done, the faster the simulation can move along. Long story short, run one client for each ''physical'' CPU, not for each ''logical'' CPU. The installer should automatically count the number of CPUs in your system. See this [http://forum.folding-community.org/viewtopic.php?t=10427 post] in the Folding@Home forums.
Line 68: Line 62:
cd $config_dir
if [[ -x $executable ]] ; then
    ./$executable -configonly
else
    # should never get here
    echo
    echo "Could not find $executable!"
    echo "If you have already downloaded it, put it in $config_dir."
    echo "If it is in $config_dir, check that it is named $executable. If not, modify $0."
    exit 1
fi

# setup a client for each processor
num_cpus=`/bin/grep '^processor[[:space:]]*:' /proc/cpuinfo | wc -l`
echo
echo "Found $num_cpus cpus. I will create one client for every cpu."
for cpu_num in `seq -w 1 $num_cpus`; do
    echo debug
    echo cpu_num = $cpu_num
    client_dir=$fah_dir/$cpu_num
    test -d $client_dir || /bin/mkdir $client_dir
    /bin/cp -f $config_dir/* $client_dir
    /bin/sed -i -e "s/machineid=.*/machineid=$cpu_num/" $client_dir/client.cfg
    cpu_num=$((++cpu_num))
done

# install the startup scripts
echo
echo "How do you want to run Folding@Home?"
echo " Daemon = Run at boot up"
echo " Manual = Copy the startup script to the Folding@Home directory ($fah_dir)."
select resp in {daemon,manual} ; do
    if [[ $resp == "daemon" ]] ; then
        if [[ $UID != 0 ]] ; then
     echo
            echo "You must be root to install as a daemon."
            exit 1
        fi
 echo
        echo "Adding startup script to /etc/init.d"
        if ! /bin/cp -vf $this_dir/foldingathome /etc/init.d/ ; then
            echo "Could not copy startup script to /etc/init.d"
            exit 1
        fi
        # hopefully 2 is the default runlevel
        runlevel=2
 echo
        echo "Adding foldingathome to runlevel $runlevel."
        if ! /bin/ln -sf /etc/init.d/foldingathome /etc/rc${runlevel}.d/S99foldingathome ; then
            echo
     echo "Could not add to runlevel $runlevel."
            exit 1
        fi
        echo
        echo "To start folding right now, run /etc/init.d/foldingathome as root."
 break
    elif [[ $resp == "manual" ]] ; then
        echo "Copying startup script to $fah_dir"
        if ! /bin/cp -fv $this_dir/foldingathome $fah_dir ; then
            echo "Could not copy startup script to $fah_dir"
            exit 1
        fi
        echo "To start folding right now, run `$fah_dir/foldingathome start`"
 break
    fi
    
done
}}}

=== Startup Script ===
{{{
#!/bin/sh

# TO DO:
# a foldingathome user

PATH=/sbin:/bin:/usr/bin
. /lib/lsb/init-functions

fah_dir=/opt/foldingathome
config_dir=$fah_dir/config
executable=FAH502-Linux.exe

# check if folding at home has been configured yet
cd $fah_dir
if [[ ! -d 1 ]] ; then
    # there will always be at least one client
    log_error_msg "Could not find client directory."
fi

num_cpu=`grep '^processor[[:space:]]*:' /proc/cpuinfo | wc --lines`

function kill_clients()
{ for cpu_num in `seq -w 1 $num_cpu` ; do
        client_dir=$fah_dir/$cpu_num
        if [[ ! -d $client_dir ]] ; then
            continue
        elif [[ $client_dir == $config_dir ]] ; then
            continue
        fi
        
        cd $client_dir
        
        log_begin_msg "Stopping Client $cpu_num."
        for client in FahCore*.exe ; do
            killall -q $client >& /dev/null
        done
        killall -q $client_dir/$executable >& /dev/null
        sleep 1
        if ps -ef | grep "$client_dir[/]$executable" >& /dev/null ; then
            # failed
            log_end_msg 1
        else
            # success
            log_end_msg 0
        fi
    done
}

function start_clients()
{ for cpu_num in `seq -w 1 $num_cpu` ; do
        client_dir=$fah_dir/$cpu_num
        if [[ ! -d $client_dir ]] ; then
            continue
        elif [[ $client_dir == $config_dir ]] ; then
            continue
        fi
        
        cd $client_dir
        log_begin_msg "Starting Client $cpu_num."
        nice -n 19 $client_dir/$executable >& /dev/null &
        log_end_msg $?
    done
}

case "$1" in
    start|force-reload)
        log_begin_msg "Starting Folding@Home"
        start_clients
        log_end_msg $?
        ;;
    restart|reload)
        log_begin_msg "Restarting Folding@Home"
        kill_clients && start_clients
        log_end_msg $?
        ;;
    stop)
        log_begin_msg "Stopping Folding@Home"
        kill_clients
        log_end_msg $?
        ;;
    *)
        log_success_msg "Usage: /etc/init.d/foldingathome {start|stop|restart}"
        exit 1
        ;;
esac

exit 0
}}}

=== Future Plans ===
Some people don't have root access to their computers. To accomodate them, a way to install to the $HOME directory should be added.

There should be a way to easily uninstall the client.

Folding@Home is secure. The Stanford team has gone to great lengths to ensure security, both for the integrity of their research and the safety of donors' computers. However, the more secure the better. The Gentoo ebuild for Folding@Home creates a new user foldingathome whose sole purpose is to run the client. I will add this feature in the future.
== Team Ubuntu ==
A competitive Folding@Home team called Team Ubuntu (FoldingAtHomeTeamUbuntu, [http://ubuntuforums.org/showthread.php?t=102313 forum thread]) has formed to represent the Ubuntu community and organize to have fun while doing some good. The team number is 45104. To join the team, simply enter 45104 when the setup dialog requests a team number. Those wishing to get optimal performance from their folding box should review the Hackaday blog entry on competitive folding linked below.
Line 236: Line 66:
http://folding.stanford.edu/  * FoldingAtHomeTeamUbuntu - wiki page for the Ubuntu F@H Team
 * [http://folding.stanford.edu/ Folding@Home Distributed Computing]
 * [http://fah-web.stanford.edu/cgi-bin/main.py?qtype=teampage&teamnum=45104 Team Ubuntu]
 * [http://www.hackaday.com/entry/1234000673058540/ HOW-TO: Folding@Home competitively]
 * [http://fahstats.com/t.php?t=45104 Folding@Home Stats for Team Ubuntu]
 * [http://folding.extremeoverclocking.com/team_summary.php?s=&t=45104 Another Stats site]
 * [http://www.ubuntuforums.org/showthread.php?t=101817 Ubuntu Forms HowTo, Based off of this page]
 * [http://ubuntuforums.org/showthread.php?t=102313 Team Ubuntu Recruiting forum thread]

Overview

When proteins are created, they undergo a complex process known as folding, so-called because the protein molecule transforms from a long chain of amino acids to a complex shape (it "folds up"). The final shape of the protein is absolutely critical to determining its properties and function. Scientists have created software to simulate the folding process to better understand how proteins work, which in turn makes it possible to develope new drugs, cure diseases, etc.

Folding@Home is a project from Stanford University that uses millions of networked PCs to form a supercomputer for protein folding simulations. The client software is loaded on a PC, it contacts the central servers, and receives "work units". The client then runs on spare CPU time, and uploads finished work units to the server.

Folding@Home is a great way to make your computer do useful work even when you're not using it. Since it runs at a very low priority, you should never realize it's running when you're using the computer to do your work. Note that "using the computer" refers to doing heavy computations. Generally, tasks like web browsing and word processing involve very little CPU usage, so the Folding@Home client will be running at near 100% even when doing those kinds of tasks. It helps to leave you computer on at all times, but is not necessary, as the project will benefit from virtually any time that the client runs on your computer.

Installation

The following script will download the latest client from the Folding@Home website, and install it to opt/foldingathome, either in / or $HOME. It will ask you to set up the client (the defaults are usually sufficient), and copy that configuration for every CPU in your machine.

  • attachment:fah_install-20060421.tar.gz

It is not possible to provide a .deb package for Folding@Home, because the client must be downloaded from Stanford's website. This is to ensure the integrity of the research.

To install, download the tarball and do

tar zxvf fah_install-version.tar.gz

This should extract the archive to a directory called fah_install/. Then

cd fah_install
less README

to read the documentation. Finally,

sudo ./folding_install.sh install

to install the client.

You can also install to your $HOME, in case you do not have root access to the computer. Clearly, you would not have to prefix the command with sudo in this case. If you install to your $HOME, a cron job will be created to start the client automatically. If you install to the system, the client will automatically start when your computer boots up.

You can reconfigure the client using the supplied reconfigure script, which is placed in opt/foldingathome. You can also give the client command line options. See the README for more details.

Laptop Systems

Because the client runs at low priority, the client should not cause the CPU governor to kick up the frequency. In other words, even though the client runs at 100% CPU usage, it should not cause the CPU frequency to go up, which keeps the fan slow and quiet. If this is not the case, then the frequency governor should be reconfigured.

One can configure ACPI (the power regulation subsystem) to stop the client when the system goes on battery power, and to start it again when the power cord is plugged back in. Edit /etc/acpi/power.sh. Inside the if [ $? = 0 ] && [ x$1 != xstop ]; then block, add

    # stop folding at home
    if [[ -x /etc/init.d/foldingathome ]] ; then 
        /etc/init.d/foldingathome stop
    fi

and inside the else block, add

    if [[ -x /etc/init.d/foldingathome ]] ; then 
        /etc/init.d/foldingathome start
    fi

This assumes that the client has been installed for the entire system, which it should be if you are able to edit files in /etc in the first place!

Other Issues

For questions and bug reports, go to the [http://ubuntuforums.org/showthread.php?t=101817 HowTo forum thread]. For casual talk about Folding@Home, use the [http://ubuntuforums.org/showthread.php?t=102313 Team Recuiting thread].

Security

Folding@Home is secure. The Stanford team has gone to great lengths to ensure security, both for the integrity of their research and the safety of donors' computers. However, the more secure the better. The Gentoo ebuild for Folding@Home creates a new user foldingathome whose sole purpose is to run the client. Now this installer offers same. It creates a user whose account is disabled, and runs the client as this user when the init script is run as root, so the client is never run as root.

Hyper Threading

For those with Hyper Threading CPUs, you probably know that an SMP kernel sees two processors. Then clearly, if you run two clients, you will get more work done than if you only run one (probably about 10-30% more). However, results that are done quickly are more useful than more results done slowly. The reason is that each work unit is a step in a giant simulation, with future steps depending on past ones. So the faster you get your work done, the faster the simulation can move along. Long story short, run one client for each physical CPU, not for each logical CPU. The installer should automatically count the number of CPUs in your system. See this [http://forum.folding-community.org/viewtopic.php?t=10427 post] in the Folding@Home forums.

Team Ubuntu

A competitive Folding@Home team called Team Ubuntu (FoldingAtHomeTeamUbuntu, [http://ubuntuforums.org/showthread.php?t=102313 forum thread]) has formed to represent the Ubuntu community and organize to have fun while doing some good. The team number is 45104. To join the team, simply enter 45104 when the setup dialog requests a team number. Those wishing to get optimal performance from their folding box should review the Hackaday blog entry on competitive folding linked below.

FoldingAtHome (last edited 2008-08-06 17:00:30 by localhost)