Intel MPI Library Python Bindings

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

The impi-rt package provides Python bindings for Intel MPI Library, enabling high-performance message passing for parallel computing. Currently at version 2021.18.0, it follows Intel's release cadence tied to Intel MPI releases. It is a runtime-only package intended for executing MPI applications; the development package (impi-devel) is separate.

pip install impi-rt
error ImportError: No module named impi_rt
cause Users incorrectly try to import from impi_rt as if it were a Python module.
fix
Do not import impi_rt directly. Use mpi4py: from mpi4py import MPI
error OSError: libmpi.so: cannot open shared object file
cause LD_LIBRARY_PATH not set or Intel MPI runtime not installed correctly.
fix
Ensure impi-rt is installed and set LD_LIBRARY_PATH to include the Intel MPI library directory (e.g., /opt/intel/mpi/lib). Alternatively, use mpirun which sets environment automatically.
error mpirun: command not found
cause Intel MPI launcher not in PATH; only the Python package impi-rt is installed, not the full Intel MPI installation.
fix
Install Intel MPI via system package or conda (conda install -c intel intelmpi) which includes mpirun.
gotcha impi-rt is the runtime package; for development, install impi-devel. Without impi-devel, you cannot compile MPI applications but can run them if the runtime is present.
fix Install impi-devel (or intel-oneapi-mpi-devel) for development headers and compiler wrappers.
breaking Intel has transitioned from pypi impi-rt to conda/OneAPI packages. The PyPI version is outdated (2021.18.0) and may not be actively maintained. Use conda with intelmpi for newer versions.
fix Use conda: conda install -c intel intelmpi -c intel mpi4py
gotcha MPI_Comm_rank and similar MPI functions are not directly available via impi-rt; you must use mpi4py bindings.
fix Use mpi4py: from mpi4py import MPI; rank = MPI.COMM_WORLD.Get_rank()

Basic MPI send/receive using mpi4py with Intel MPI runtime. Run with 'mpirun -np 2 python script.py'.

from mpi4py import MPI
import numpy as np

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
data = np.array([rank + 1], dtype=np.int32)
if rank == 0:
    comm.Send(data, dest=1)
    print(f"Rank 0 sent {data[0]}")
elif rank == 1:
    recv = np.zeros(1, dtype=np.int32)
    comm.Recv(recv, source=0)
    print(f"Rank 1 received {recv[0]}")