mpi4py installations are tied to a particular MPI variant, and there are many. Your best option is to install it yourself. Recommended:
- use vanilla python, pick an MPI variant and version of your choice and install mpi4py into a virtual environment using pip OR
- use conda, pick an MPI variant and version of your choice and install mpi4py into a conda environment using pip
Suitable MPI installations are for example
- openmpi/3.1.6: module load maxwell openmpi/3.1.6
- openmpi/4.0.4: module load maxwell openmpi/4.0.4
Both openmpi versions come with various pre-installed mpi4py:
for py in python/3.9 python/3.10 python/3.7 python/3.6 conda/3.9 conda/3.8 conda/3.6 ; do echo $py module purge module load maxwell $py openmpi/4.0.4 python3 -c 'from mpi4py import MPI; import mpi4py; print("mpi4py ",mpi4py.__version__)' done python/3.9: mpi4py 3.1.3 python/3.10: mpi4py 3.1.3 python/3.7: mpi4py 3.1.3 python/3.6: mpi4py 3.1.1 conda/3.9: mpi4py 3.1.3 conda/3.8: mpi4py 3.1.3 conda/3.6: mpi4py 3.1.1
Note: the order of modules loaded matters! The python module has to be loaded before the openmpi module to set the right PYTHONPATH for the python version!
When installing your own mpi4py make sure to
- unset PYTHONPATH
after loading the openmpi module.