MPI for Python (mpi4py)
MPI for Python is an implementation of language bindings for Python of the MPI parallel computing framework.
MPI for Python (mpi4py) requires an environment module
In order to use MPI for Python (mpi4py), you must first load the appropriate environment module:
module load gnu openmpi
This package allows access to MPI function calls and allows the user to leverage multiple processors to run their code natively in Python without having to use other bindings for MPI such as C or Fortran.
Running MPI for Python on the HPC#
MPI for Python is a native Python library that allows access to the MPI framework for parallel processing. Once you have
loaded the requisite environment modules (
module load gnu openmpi), you can then run your Python script using the
Submitting a mpi4py Job to Slurm#
Below is an example script that uses four processes:
For example Python scripts that you can use for testing, refer to the official tutorial.