mpi4py lets Python programs use MPI. With it, one program can run on many processors across many nodes. Don't load other MPI modules with it. They can clash and make jobs fail. Install mpi4py with conda, not pip.
Loading mpi4py
- module
mpi4py/latest - module
anaconda/3
which after loading.Example usage
Load the system mpi4py module
module load mpi4py/latest
Create a conda environment with mpi4py
module load anaconda/3 conda create --name my_parallel_env mpi4py numpy pandas source activate my_parallel_env
Run an mpi4py script
mpirun -n $SLURM_NTASKS python my_script.py
Example Python script
from mpi4py import MPI comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size() print(f"Hello from process {rank} out of {size}!") Availability
mpi4py is available on: SeaWulf, NVwulf, ClinWulf.