Open MPI

raw JSON →
5.0.10 verified Fri May 01 auth: no python

Open MPI is a high performance implementation of the Message Passing Interface (MPI) standard, used for parallel computing. The Python package 'openmpi' is a wrapper that provides MPI bindings for Python. Current version is 5.0.10. Release cadence is irregular, following upstream Open MPI releases.

pip install openmpi
error ImportError: No module named mpi4py
cause mpi4py is not installed; openmpi package alone does not provide Python bindings.
fix
Run 'pip install mpi4py' and ensure the system has an MPI implementation (e.g., Open MPI).
error OSError: libmpi.so: cannot open shared object file: No such file or directory
cause The underlying MPI library (e.g., Open MPI) is not installed on the system or not in the library path.
fix
Install Open MPI using your package manager: 'sudo apt install libopenmpi-dev' (Ubuntu) or 'brew install open-mpi' (macOS).
error MPI_Comm_spawn failed with error code 12
cause Insufficient resources or misconfigured process manager (ORTE/PRRTE).
fix
Check system limits (ulimit -u), ensure PRTE daemon is running, or use '--oversubscribe' flag with mpirun.
gotcha The 'openmpi' PyPI package may not provide Python bindings directly; actual MPI programming in Python typically uses 'mpi4py'. Ensure mpi4py is installed and that the underlying Open MPI library is available on your system.
fix Use mpi4py instead. Install via: pip install mpi4py
breaking Open MPI 5.x is not backward compatible with Open MPI 4.x custom MPI extensions. User-defined functions that rely on internal MPI hooks may break.
fix Review application code for any non-standard MPI usage; consult Open MPI 5 migration guide.
deprecated The 'ompi' command-line tool has been deprecated in favor of 'prrte' for runtime launch. Using 'mpirun' is still supported but may emit warnings.
fix Use 'mpirun' or switch to 'prrte' launcher if needed.
gotcha Open MPI requires a compatible Fortran compiler at build time; if you compile from source, you may need to install gfortran. Pre-built Python wheels may not be available.
fix Install system-level Open MPI via package manager (e.g., apt, brew) before using mpi4py.

Initialize MPI, get rank and size, and perform a simple send/receive.

from mpi4py import MPI

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()

print(f"Hello from rank {rank} of {size}")

# Example: send and receive
if rank == 0:
    data = {'a': 7, 'b': 3.14}
    comm.send(data, dest=1)
elif rank == 1:
    data = comm.recv(source=0)
    print(f"Rank 1 received: {data}")