Why?

You will need OpenMPI for cluster communication. But, when using a standard command like:

# Don't Do This
sudo apt-get install openmpi-bin

You will get an older version of OpenMPI. In my case it was 3.1.3:

$ mpiexec --version
mpiexec (OpenRTE) 3.1.3

I noticed some errors when running this, so I wanted to install the latest version, which was 4.1.1.

Each Node?

I need a newly built version on every node. I just built it on each node, but a better way is probably to build it once and then copy all the files in the bin directory over to the new node. If I ever rebuild this, like if there is a new version, then I will try this.

Remove Conflicts

Make sure there are no other MPI implementations installed. They are not there by default, but if you installed them previously they could (and probably will) conflict.

sudo apt-get remove mpich
sudo apt-get remove openmpi-bin
sudo apt-get autoremove

All-in-one script

This script will download OpenMPI and install it for the raspberry pi. The whole process takes about 30 minutes on a raspberry pi.

#!/bin/bash

# cleanup
sudo rm -rf /home/matt/openmpi

# setup
mkdir -p /home/matt/openmpi/{build,code,install}

# Get the code
cd /home/matt/openmpi/
wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.1.tar.gz
tar -xzvf openmpi-4.1.1.tar.gz -C /home/matt/openmpi/code

# Get to the right place
cd /home/matt/openmpi/build

# Start the build process
sudo /home/matt/openmpi/code/openmpi-4.1.1/configure -prefix=/home/matt/openmpi/install |& tee config.out
sudo make -j 8 |& tee make.out
sudo make install |& tee install.out

Move executables

Make sure the executables are on the path:

cp /home/matt/openmpi/install/bin/* /home/matt/bin/

I mentioned this in the page on building stockfish, but if you do not have a bin directory in your home directory, you can create one and then log out and back in. On the Raspberry Pi it will automatically add that to your path.

Can’t find /home/matt/bin/orted?

This is one problem I encountered that had me scratching my head. I think this has to do with not being able to find that path when logging in with a non-interactive shell. It looks like you can call the full path of the mpirun file to fix it like this:

/home/matt/bin/mpirun

Another problem is if the orted file is not in the same place on all the cluster worker nodes.

More Information

Here are some of the places I looked to help me build this: