Skip to main content

Python bindings for MPI

Project description

This package provides Python bindings for the Message Passing Interface (MPI) standard. It is implemented on top of the MPI specification and exposes an API which grounds on the standard MPI-2 C++ bindings.

Features

This package supports:

  • Convenient communication of any picklable Python object

    • point-to-point (send & receive)

    • collective (broadcast, scatter & gather, reductions)

  • Fast communication of Python object exposing the Python buffer interface (NumPy arrays, builtin bytes/string/array objects)

    • point-to-point (blocking/nonblocking/persistent send & receive)

    • collective (broadcast, block/vector scatter & gather, reductions)

  • Process groups and communication domains

    • Creation of new intra/inter communicators

    • Cartesian & graph topologies

  • Parallel input/output:

    • read & write

    • blocking/nonblocking & collective/noncollective

    • individual/shared file pointers & explicit offset

  • Dynamic process management

    • spawn & spawn multiple

    • accept/connect

    • name publishing & lookup

  • One-sided operations

    • remote memory access (put, get, accumulate)

    • passive target synchronization (start/complete & post/wait)

    • active target synchronization (lock & unlock)

Install

Using pip

You can install the latest mpi4py release from its source distribution at PyPI using pip:

$ python -m pip install mpi4py

You can also install the in-development version with:

$ python -m pip install git+https://github.com/mpi4py/mpi4py

or:

$ python -m pip install https://github.com/mpi4py/mpi4py/tarball/master

Using conda

The conda-forge community provides ready-to-use binary packages from an ever growing collection of software libraries built around the multi-platform conda package manager. Four MPI implementations are available on conda-forge: Open MPI (Linux and macOS), MPICH (Linux and macOS), Intel MPI (Linux and Windows) and Microsoft MPI (Windows). You can install mpi4py and your preferred MPI implementation using the conda package manager:

  • to use MPICH do:

    $ conda install -c conda-forge mpi4py mpich
  • to use Open MPI do:

    $ conda install -c conda-forge mpi4py openmpi
  • to use Intel MPI do:

    $ conda install -c conda-forge mpi4py impi_rt
  • to use Microsoft MPI do:

    $ conda install -c conda-forge mpi4py msmpi

MPICH and many of its derivatives are ABI-compatible. You can provide the package specification mpich=X.Y.*=external_* (where X and Y are the major and minor version numbers) to request the conda package manager to use system-provided MPICH (or derivative) libraries. Similarly, you can provide the package specification openmpi=X.Y.*=external_* to use system-provided Open MPI libraries.

The openmpi package on conda-forge has built-in CUDA support, but it is disabled by default. To enable it, follow the instruction outlined during conda install. Additionally, UCX support is also available once the ucx package is installed.

Linux

On Fedora Linux systems (as well as RHEL and their derivatives using the EPEL software repository), you can install binary packages with the system package manager:

  • using dnf and the mpich package:

    $ sudo dnf install python3-mpi4py-mpich
  • using dnf and the openmpi package:

    $ sudo dnf install python3-mpi4py-openmpi

Please remember to load the correct MPI module for your chosen MPI implementation:

  • for the mpich package do:

    $ module load mpi/mpich-$(arch)
    $ python -c "from mpi4py import MPI"
  • for the openmpi package do:

    $ module load mpi/openmpi-$(arch)
    $ python -c "from mpi4py import MPI"

On Ubuntu Linux and Debian Linux systems, binary packages are available for installation using the system package manager:

$ sudo apt install python3-mpi4py

Note that on Ubuntu/Debian systems, the mpi4py package uses Open MPI. To use MPICH, install the libmpich-dev and python3-dev packages (and any other required development tools). Afterwards, install mpi4py from sources using pip.

macOS

macOS users can install mpi4py using the Homebrew package manager:

$ brew install mpi4py

Note that the Homebrew mpi4py package uses Open MPI. Alternatively, install the mpich package and next install mpi4py from sources using pip.

Windows

Windows users can install mpi4py from binary wheels hosted on the Python Package Index (PyPI) using pip:

$ python -m pip install mpi4py

The Windows wheels available on PyPI are specially crafted to work with either the Intel MPI or the Microsoft MPI runtime, therefore requiring a separate installation of any one of these packages.

Intel MPI is under active development and supports recent version of the MPI standard. Intel MPI can be installed with pip (see the impi-rt package on PyPI), being therefore straightforward to get it up and running within a Python environment. Intel MPI can also be installed system-wide as part of the Intel HPC Toolkit for Windows or via standalone online/offline installers.

Citation

If MPI for Python been significant to a project that leads to an academic publication, please acknowledge that fact by citing the project.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpi4py-4.0.0.tar.gz (464.8 kB view hashes)

Uploaded Source

Built Distributions

mpi4py-4.0.0-pp310-pypy310_pp73-win_amd64.whl (1.6 MB view hashes)

Uploaded PyPy Windows x86-64

mpi4py-4.0.0-pp39-pypy39_pp73-win_amd64.whl (1.6 MB view hashes)

Uploaded PyPy Windows x86-64

mpi4py-4.0.0-pp38-pypy38_pp73-win_amd64.whl (1.7 MB view hashes)

Uploaded PyPy Windows x86-64

mpi4py-4.0.0-pp37-pypy37_pp73-win_amd64.whl (1.7 MB view hashes)

Uploaded PyPy Windows x86-64

mpi4py-4.0.0-cp312-cp312-win_amd64.whl (1.7 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

mpi4py-4.0.0-cp311-cp311-win_amd64.whl (1.6 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

mpi4py-4.0.0-cp310-cp310-win_amd64.whl (1.6 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

mpi4py-4.0.0-cp39-cp39-win_amd64.whl (1.6 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

mpi4py-4.0.0-cp38-cp38-win_amd64.whl (1.6 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

mpi4py-4.0.0-cp37-cp37m-win_amd64.whl (1.6 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

mpi4py-4.0.0-cp36-cp36m-win_amd64.whl (1.8 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page