Why?

If you were to do sudo apt-get install stockfish on a raspberry pi, you would get stockfish 9 (13 is the latest). You also would not get the special code that handles clusters..

For that, you need to use the cluster branch

Build the Cluster Version

First, clone the branch. This --single-branch only gets the cluster branch since that is all I need.

git clone --branch cluster --single-branch https://github.com/official-stockfish/Stockfish.git stockfish-cluster

Now, build the executable. ARCH is for Raspberry Pi. COMPILER is the OpenMPI cluster compiler. Make sure to do this after you have built OpenMPI otherwish you will have problems when you go to run stockfish.

cd stockfish-cluster/src
make -j ARCH=armv7 COMPILER=mpicxx clean build

Parameters:

  • -j - if given without an argument, make will not limit the number of jobs that can run simultaneously
  • ARCH=armv7 - The architecture of the raspberry pi to build for
  • COMPILER=mpicxx - use the OpenMPI compiler so we can use this across clusters

Latest NNUE Files

If you want a newer neural-network training file, you get get that here: https://tests.stockfishchess.org/nns. It should happen automatically during build. However, I had some issues downloading the file once.

You can also set new training files during execution:

setoption name EvalFile value /home/matt/nnue/nn-8a08400ed089.nnue

Note: Currently that nn-8a08400ed089.nnue file won’t work because it is based on a new architecture. Need to let the cluster branch catch up.

Move to ~/bin

First, make a new user-specific bin directory

mkdir ~/bin

Then log out and log back in and you will see that the /home/matt/bin directory will be in your path.

echo $PATH

Now copy the executable you built into the new ~/bin directory:

cp stockfish-cluster/src/stockfish ~/bin/stockfish

Or you could just create a link

ln -s /home/matt/stockfish-cluster/src/stockfish ~/bin/stockfish

Copy stockfish to each worker node

scp ~/bin/stockfish matt@stockfish1.local:/home/matt/bin/stockfish

Changes to sourcecode

I updated the default number of threads and hash. This is in src/ucioption.cpp. I did this because I had occasional issues setting UCI options from SCID. Instead I just defaulted the options to a higher value. I used 3 threads and 256 hash.

References: