Question about MPI
Hi,
We are trying to run MPI with Python, and we encounter a problem.
We didn't find any solution in the web.
By running 'mpirun -np 2 python try.py', the MPI does not recognize the fact that 2 processes are running and print us rank 0 for both processes.
by running this simple program with the command: 'mpirun -np 2 python try4.py'
from mpi4py import MPI
import sys,os
hwmess = "Hello, World!! I am process %d of %d on %s.\n"
myrank = MPI.COMM_WORLD.Get_rank()
nprocs = MPI.COMM_WORLD.Get_size()
procnm = MPI.Get_processor_name()
sys.stdout.write(hwmess % (myrank, nprocs, procnm))
v = os.getpid()
MPI.COMM_WORLD.Send(v,0)
data=MPI.COMM_WORLD.Recv(0)
counter = 0
while True:
if counter == 1000000:
print "I'm",os.getpid(),"my rank",myrank,"I got",data
counter = 0
counter = counter + 1
the output I get is:
Hello, World!! I am process 0 of 1 on inferno-03.cs.huji.ac.il.
Hello, World!! I am process 0 of 1 on inferno-03.cs.huji.ac.il.
I'm 21599 my rank 0 I got 21599
I'm 21601 my rank 0 I got 21601
I'm 21599 my rank 0 I got 21599
I'm 21601 my rank 0 I got 21601
I'm 21599 my rank 0 I got 21599
I'm 21601 my rank 0 I got 21601
Do you have any idea what's wrong and how can we fix it?
Any help will be appreciated.
Thanks you very much,
Last edited by sara.vilner; 01-16-2009 at 03:47 AM.
Reason: not clear
|