MPI4PY is a package that enables Python programs to run
in parallel under MPI.
MPI4PY provides an interface designed on translating MPI syntax and
semantics from standard MPI-2 C++ bindings to Python. As syntax
translation from C++ to Python is generally straightforward, any user
with some knowledge of those C++ bindings should be able to use this
package without learning a new interface.
The home page “MPI for Python” at pythonhosted.org:
Lisandro Dalcin, Rodrigo Paz, Mario Storti,
MPI for Python,
Journal of Parallel and Distributed Computing,
Volume 65, pages 1108-1115, 2005.
ARC has not installed MPI4PY on any of its clusters. However, it is
possible for a user to install MPI4PY, and then to use it in the usual way.
Example User Installation on NewRiver:
In this example, the user PID has decided to create a subdirectory
tfcascades into which to install TENSORFLOW. The user PID
should log in interactively to NewRiver and issue the following commands:
module purge module load gcc/5.2.0 module load openmpi/1.8.5 module load Anaconda/2.3.0 export PYTHONUSERBASE=/home/PID/newriver/python pip install --user mpi4py
Example Usage on NewRiver:
We assume MPI4PY has been installed as in the above example.
A simple test code might be the following “hello_mpi.py”:
def hello_mpi ( ): import sys from mpi4py import MPI comm = MPI.COMM_WORLD id = comm.Get_rank() p = comm.Get_size() if ( id == 0 ): print "" print "HELLO_MPI:" print " P", id, ": There are ", p, " MPI processes running." print " P", id, ": Hello, world!"
Then a typical batch job to run the code under MPI4PY might be:
#! /bin/bash # #PBS -l walltime=00:05:00 #PBS -l nodes=1:ppn=4 #PBS -W group_list=newriver #PBS -q open_q #PBS -j oe # cd $PBS_O_WORKDIR # module purge module load gcc/5.2.0 module load Anaconda/2.3.0 module load openmpi/1.8.5 # export PYTHONUSERBASE=/home/burkardt/newriver/python # mpirun -np 4 python hello_mpi.py
A complete set of files to carry out a similar process are available in