Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get mpi4py to work on Windows

I'm trying to use mpi4py.

I have mpi4py installed from the Anaconda package, and

pip install mpi4py

recognizes this.

But when i run

from mpi4py import MPI

says MPI module doen't exist.

I've looked in the mpi4py folder and indeed i can't find it.

i think the problem is that i might not have OpenMPI installed, but i've been looking everywhere and i can't find how to install ir on Windows 10.

Please help.

Edit: The original question was about installing OpenMPI on windows 10 and use it with mpi4py, but since i found a way to run mpi4py with MSMPI i changed the title so people trying to do the same at least have a work-around.

like image 875
alxg Avatar asked May 22 '16 00:05

alxg


People also ask

How do I run an mpi4py program?

Execute the Python code contained in pyfile, which must be a filesystem path referring to either a Python file, a directory containing a __main__.py file, or a zipfile containing a __main__.py file. Search sys. path for the named module mod and execute its contents. Execute the Python code in the cmd string command.

How do I play MPI files on Windows?

To use MPI with Windows, you will need to install the free download of Microsoft MPI. Go to the installation page and download MSMpiSetup.exe . Once downloaded, run the executable and follow the instructions. If you want to set the PATH permanently, follow these instructions.


1 Answers

Set the MSMPI path (by default C:\Program Files\Microsoft MPI\Bin) in the %PATH% environment variable (http://www.computerhope.com/issues/ch000549.htm).

After that, you can launch your program by running the command:

mpiexec /np <number of process> python <your MPI4Py python script>
like image 57
user6658022 Avatar answered Sep 20 '22 12:09

user6658022