I am trying to run existing code in parallel. The parallelization done before and is used by colleagues perfectly. On my machine, I am running into some problems I could not find a solution for.
I narrowed the problem to a simple thing:
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
print "Rank: %i; size: %i"%(rank, size)
I am running this with mpirun -np 5 python test.py
and get the following output:
Rank: 0; size: 1
Rank: 0; size: 1
Rank: 0; size: 1
Rank: 0; size: 1
Rank: 0; size: 1
Which basically duplicates the code instead of considering the number of process specified.
Adding these lines yield the same error message from my main code:
if rank == 0:
data = {'a': 7, 'b': 3.14}
comm.send(data, dest=1, tag=11)
elif rank == 1:
data = comm.recv(source=0, tag=11)
The following error message appears:
mpi4py.MPI.Exception: Invalid rank, error stack:
MPI_Send(174): MPI_Send(buf=0x7f31851f3a54, count=25, MPI_BYTE, dest=1, tag=11, MPI_COMM_WORLD) failed
MPI_Send(100): Invalid rank has value 1 but must be nonnegative and less than 1
I found the question MPI_Send(100): Invalid rank has value 1 but must be nonnegative and less than 1 but I'm already using the command in the accepted answer and couldn't find anything similar.
I am using Python 2.7 and running on Centos 6.7. Thanks in advance !