Installing mpi4py for use with Python and MPI



Via Ubuntu Linux Super Computer, all nodes (you can do all of this on just 1 device, however):

On all nodes:

sudo apt-get install python

sudo apt-get install python-mpi4py

cd ~

sudo mkdir mpi4py

cd mpi4py

wget http://mpi4py.googlecode.com/files/mpi4py-1.3.tar.gz

tar xfz mpi4py-1.3.tar.gz

cd mpi4py-1.3/demo

Just the master node now:

mpirun.openmpi -np 2 -machinefile /home/pi/mpi_testing/machinefile python helloworld.py

For the above code, you will need that machine file to exist. We placed ours from the building a super computer tutorial in the /home/pi/mpi_testing/ directory under the name of machinefile. The contents of the machine file are just the local IP addresses listed out, separated by new lines.

supercomputing tutorial

To get the local IP address, usually 192.168.x.x, type "ifconfig" in your shell.

From the test we ran, you should get some simple helloworld output. If not, you should go back and look everything over!


There exists 1 quiz/question(s) for this tutorial. for access to these, video downloads, and no ads.

The next tutorial:





  • Build a Supercomputer with Raspberry Pis
  • Intro
  • Supplies
  • Installing Operating System
  • Downloading and installing MPI
  • Testing Supercomputer
  • MPI with MPI4py Introduction
  • Installing mpi4py for use with Python and MPI
  • First basic MPI script with mpi4py
  • Using conditional, Python, statements alongside MPI commands example
  • Getting network processor size with the size command
  • Sending and Receiving data using send and recv commands with MPI
  • Dynamically sending messages to and from processors with MPI and mpi4py
  • Message and data tagging for send and recv MPI commands tutorial
  • MPI broadcasting tutorial with Python, mpi4py, and bcast
  • Scatter with MPI tutorial with mpi4py
  • Gather command with MPI, mpi4py, and Python