Problem with mpi4py module

3

I found an interesting module to do parallel calculations with python but when using the documentation it tells me that the code to start using the module is this but when I try to execute the code I get an error:

from mpi4py import MPI

comm = mpi4py.MPI.COMM_WORLD
rank = comm.Get_rank()
print "HOla", rank

but I get this error in the console

  

C: \ Users \ LUIGGI-S> C: \ Users \ LUIGGI-S \ Desktop \ cluster.py   Traceback (most recent call last):     File "C: \ Users \ LUIGGI-S \ Desktop \ cluster.py", line 3, in       comm = mpi4py.MPI.COMM_WORLD   AttributeError: 'module' object has no attribute 'MPI'

What could be the solution?

    
asked by jorgemorales 16.08.2016 в 00:20
source

2 answers

1

Do you have MPI installed? As you are in Windows maybe the easiest is using

If installing the details in the previous link does not solve the problem, take a look at:

  • The official documentation of mpi4py .

For completing the answer, there are other options to run parallelized code in Python. Depending on what you want to do some solutions will adjust better or worse:

answered by 17.08.2016 / 10:56
source
1

I think it's an error in your code. In the official tutorial link you have:

from mpi4py import MPI

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

While you have written

from mpi4py import MPI

comm = mpi4py.MPI.COMM_WORLD  # <--- ¡Aquí!
rank = comm.Get_rank()

Try exactly the tutorial code so that you do not have MPI installed and you are not accessing it well.

    
answered by 18.08.2016 в 12:57