How to Make a Raspberry Pi SuperComputer!





Introduction: How to Make a Raspberry Pi SuperComputer!

By itself the Raspberry Pi doesn't boast impressive specs. But with the dirt cheap price, buying several of these and connecting them to use they're combined processing power could potentially make a decent low cost computer. There have been several impressive rigs built connecting dozen's of Pi's together. So in this instructable, let's explore how the technology behind cluster computing and make our own Bramble Pi!

Step 1: Watch the Video Version

I've also made a two part video version of this exact same project. So if you're not one for reading, kick back and watch the vids! Please note that the video version uses Raspbian Wheezy. However, the instructions below are for the current Raspbian Distro, which is Jessie at the time I am writing this.

Step 2: What You Will Need

To follow along with this project, here are the parts you will need to acquire

Here’s what you will need:

  1. 2 or more Raspberry Pi’s
  2. SD cards for each Pi
  3. Power Cables for each Pi
  4. Powered USB Hub (optional)
  5. Networking Cables
  6. A Hub or a Router

TOTAL COST: ~$100.00

Step 3: Installing and Configuring Raspbian

Once you have all the parts, the next step is to download and configure Raspbian OS on one of the Raspberry Pi's. This will be your master Pi. Here's the steps:

  1. Download the Raspbian Image from here.
  2. Burn the Raspbian image to each SD Card you have for each Raspberry Pi.
    1. If you have Windows, you can follow these instructions.
    2. If you have a Mac, you can follow these instructions.
  3. Once the image is burned to your SD Card, put it into each of the Raspberry Pi and boot it up.
  4. Upon first boot, you should see the Rasbperry Pi Desktop. Click on the menu icon in the upper lefthand corner and go to Preferences > Raspberry Pi Configuration. Here’s the options we’ll need to configure
    1. Expand the File SystemIf needed.
    2. Change the hostname to Pi01
    3. Change the boot option to CLI (Command Line Interface), since we won't really be using the Desktop Interface.
    4. Clock on the "Interfaces" tab and make sure SSH is enabled.
    5. Click on the "Overclock" tab and choose "Turbo".
    6. Change the GPU memory to 16mb.
    7. Click on the "Localization" tab and set your keyboard layout to match that of your countries.
    8. Finish out of the configuration, and reboot your Pi.

Step 4: Installing MPICH

Still using only the one Pi as the master, we now need to install the primary software that is going to allow us to use the processing power of all the Pi's on our network. That software is called MPICH, which is a Message Passing Interface. Here's what you need to do to install it:

sudo apt-get update

mkdir mpich2

cd ~/mpich2


tar xfz mpich-3.1.tar.gz

sudo mkdir /home/rpimpi/

sudo mkdir /home/rpimpi/mpi-install

mkdir /home/pi/mpi-build

cd /home/pi/mpi-build

sudo apt-get install gfortran

sudo /home/pi/mpich2/mpich-3.1/configure -prefix=/home/rpimpi/mpi-install

sudo make

sudo make install

nano .bashrc


sudo reboot

mpiexec -n 1 hostname

These commands will download and install MPICH, as well as add it as a path to your BASHRC boot file. The last command runs a test to see if it works. If the last command returns “Pi01”, then you did everything successfully.

Step 5: Installing MPI4PY

As it is, MPICH can run C and Fortran programs. But since the Raspberry Pi has the Python coding environment pre-installed, it would be easiest to install a Python to MPI interpreter. Here’s the commands to do that:

sudo aptitude install python-dev


tar -zxf mpi4py-1.3.1

cd mpi4py-1.3.1

python build

python install

export PYTHONPATH=/home/pi/mpi4py-1.3.1

mpiexec -n 5 python demo/

That last command should return five responses. Each one is a different process on Pi01 running the python program "Hello World" that we just made.

Step 6: Copying the Image

Now that we've successfully configured our master Pi, we need to copy that Pi's SD card image to all the other Pi's. Here's how you can do that on Windows:

  1. Take the master SD Card out of the Pi and insert it into your computer.
  2. Using Win32DiskImager, use the "Read" button to save the contents of the SD card to your computer.
  3. Eject the master SD Card and insert an SD card for one of the other Pi's. Then use the Win32DiskImager "Write" option to write the image we saved to the new SD Card.
  4. Repeat step 3 until you have the master image written to all of the SD cards.

Step 7: Configuring the Remaining Raspberry Pi's

Now that we have all of the SD Cards prepped, insert the Master SD Card back into the Master Pi, connect it to a router and boot it back up. Then for the remaining Raspberry Pi's, insert SD Cards into all of them, connect them to the same router as your Master Pi, and then boot them all up. None of the secondary Pi's need to have keyboards, mice, or monitors.

Once all of the Pi's are powered on, using our Master Pi, we should be able to get the IP addresses of each Pi on the network. Here's how:

  1. First Install NMAP
    sudo apt-get update
    sudo apt-get install nmap
  2. Then get the current IP for the master Pi
  3. Now you can scan your routers subnet for the other Pi IP addresses
    sudo nmap -sn 192.168.1.*

Copy down all of the IP addresses that pertain to the other Raspberry Pi's on the network. We will then be able to use those IP's to connect into each of the other Pi's using SSH. What we need to do first is rename each of the secondary Pi's to a unique network name. Right now they're all set to Pi01. Assuming that one of the secondary Pi's IP addresses is, here's how you can connect to it and change it's name:

  1. Establish an SSH connection
    ssh pi@
  2. Run raspi-config
    sudo raspi-config
  3. In the interface, scroll down to the Advanced option, and then choose Hostname.
  4. For the hostname, change Pi01 to the next sequential number, which is Pi02.
  5. Then exit out of the SSH session

You want to repeat those steps for each of the other Pi's on the network renaming them to Pi03, Pi04, etc.

On your master Pi, you want to create a new textfile called "machinefile"

nano machinefile

And in it, you want to type in each of the Pi's IP addresses (including the Master IP address) on a new line and then save the file.

At this point, we could run a test file using mpiexec -f machinefile -n 4 hostname, but it will error out saying that there was a "host key verification failure". So in the next step, let's fix that.

Step 8: Verifying Host Keys

To fix it so that communicating with each Pi doesn't result in a host key verification failure, we need to create and swap keys for each of our Raspberry Pi's. This part may get slightly complicated, but hopefully you can stay with me.

  1. On the Master Pi, in the default home folder, create a new key.
  2. Navigate to the ssh folder and copy the key file to a new file called "pi01"
    cd .ssh
    cp pi01
  3. Next you want to connect via SSH into Pi02 and repeat those same steps to create a Pi02 keyfile
    ssh pi@
    cd .ssh
    cp pi02
  4. Before exiting out of Pi02, we need to copy the Pi01 keyfile over to it and authorize it.
    scp .
    cat pi01 >> authorized_keys
  5. With Pi02 done, repeat all of those steps for Pi03
    ssh pi@
    cd .ssh
    cp pi03
    scp .
    cat pi01 >> authorized_keys
  6. Repeat the last step for the remaining Pi's that you have on your network.
  7. After generating keys for each of the Pi's, exit back to your Master Pi and copy over all of the keys generated on each of the Pi's.
    cat pi02 >> authorized_keys
    cat pi03 >> authorized_keys
    cat pi04 >> authorized_keys
    (repeat for as many Pi's are on your network)

Step 9: Running a Program on Your Supercomputer

Now everything should be set up. While still on your Master Pi, try running this machinefile again:

cd ~
mpiexec -f machinefile -n 4 hostname

If everything was done correctly, it should return the IP addresses of all your Raspberry Pi's. Now that we've successfully tested out our supercomputer, lets run a python program on it:

  1. Download and unzip my test Python password cracking script.
    tar -zxf python_test.tar.gz
  2. Edit the password hash to one that you'd like to crack.
    nano python_test/
  3. Copy the Python file to all of your Pi's.
    scp -r python_test
    scp -r python_test
    scp -r python_test
    (repeat for all remaining Pi's)
  4. Run the python script.
    mpiexec -f machinefile -n 5 python python_test/

The script will run using the processing power of all of the Pi's on your network! Feel free to test it out using your own python script!

Raspberry Pi Contest 2016

Third Prize in the
Raspberry Pi Contest 2016



    • Clocks Contest

      Clocks Contest
    • Oil Contest

      Oil Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    92 Discussions

    mpiexec -f machinefile -n 5 python python_test/

    mpiexec: Error: unknown option "-f"

    Type 'mpiexec --help' for usage.

    Can I use two diffwnet models of Pi's and will this set of instructions work for raspbian stretch?

    mpi.h missing, python build fails again. After numerous fails including 'apt update --fix-missing', reverting to boinc-client. Good grief.

    2 more answers

    This could be a CD card issue, I had the similar problem, and I found that the running 'apt update --fix-missing' wont help until you reinstal OS or change CD.


    Thanks -- I reckon you could be on to something. I'll check this asap. o7

    for some reason, this video led me to different videos in the similar to the video section for hours and that made me interested in a bitcoin miner. Otherwise, great project

    hi guys need help . i am stuck at ssh-keygen . It shown Generating public/private rsa key pair. then shown " Enter file in which to save the key (/home/pi/.ssh/id_rsa):pi@Pi01:~$ . I press enter it does
    not shown anything except pi@Pi01:~$ . i try put file name is does not work . i am new in this . please help thank you

    1 reply

    already done . just reboot

    mpi4py can be found on as of Jan 2018 (


    11 months ago

    Hello; When I try to this command scp I am getting "port 22 connection refused" error message between copy key Pi02 to Pi01 via ssh connection Do you have any comment about it

    1 reply

    If you are still having this issue, verify that the IP is correct, and that you have ssh enabled on the image, you can do that any of two ways, by either connecting directly to it and turning on the ssh (monitor ,kb,mouse...) or you can insert the card into yoru desktop(or laptop or tablets) card reader, open the boot and add a new empty file named 'ssh' sans the quotes... reinsert card in pi and try again :)

    I just wanted to try it out since the raspberry pi fascinated me. so I created a master on my pi 3 and plan on creating my nodes/slaves on pi 0 W. As I have stated I have the master completed, after two attempts. When the entire project is completed I will post. Great Project!!!!

    Hi, I'm a writer in South Korea.

    Now I'm writing a book about Raspberry Pi.

    I want to introduce this project in my book.

    Can I introduce this project in my book?

    At first vey geat tutorial. Everything works.

    Anybody got python 3 running with mpi4py?

    I tryed to build it from source but always an error. The google code Link isn`t working anymore.

    I replaced:

    python build


    sudo python3 build

    but it isn`t working I get following error

    within "...........................

    _congfigtest 2:c:17: fatal error: mpi_h


    1 reply

    hello great instructable im currently stuck at this part though im not sure if its because its a pi 3 please help

    everything was going fine until

    nano .bashrc


    sudo reboot

    mpiexec -n 1 hostname

    every time i type the nano .bashrc it starts something like ther terminal but works more like a text document, yes im a bit new to the rpi community so sorry if its a lame question lol

    1 reply

    exactly nano is a text editor ;) Just go down with to the file and add the path.

    also check out the first vid it shows the trick. a lil bit fast maybe but you will get it I guess. press the Enter and x-button for exit and save.


    11 months ago

    I have built a cluster Raspberry as in your guide successfully. Thanks Gigafide so much, it fairly useful. However, in my project, I would like to send data from computer to a cluster Raspberry by using an Ethernet port, then the Master will send this data to the slaves Raspberry like in your system of Raspberry Pi SuperComputer. Can you show me the way to do this? Best regard,Grab


    11 months ago

    I have built a cluster Raspberry as in your guide successfully. Thanks Gigafide so much, it fairly useful. However, in my project, I would like to send data from computer to a cluster Raspberry by using an Ethernet port, then the Master will send this data to the slaves Raspberry like in your system of Raspberry Pi SuperComputer. Can you show me the way to do this?

    Best regard,


    ok i have done this so many times now everything works until i try the test command after the reboot but all i get is that theres no such command, so how do i use this ¨mpiexec -n 1 hostname¨ to test that it worked because i have gotten everything up to that point done code for code command for command.