I have a problem with running a python Hello World mpi4py code on a virtual machine.
The hello.py code is:
#!/usr/bin/python
#hello.py
from mpi4py import MPI
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()
print "hello world from process ", rank,"of", size
I've tried to run it using mpiexec and mpirun, but it is not running well. The output:
$ mpirun -c 4 python hello.py
hello world from process 0 of 1
hello world from process 0 of 1
hello world from process 0 of 1
hello world from process 0 of 1
And from mpiexec:
$ mpiexec -n 4 python hello.py
hello world from process 0 of 1
hello world from process 0 of 1
hello world from process 0 of 1
hello world from process 0 of 1
They seem not getting rank and size of comm. What can cause this? How to solve it?
mpiexec --version
mpiexec (OpenRTE) 1.6.5
mpirun --version
mpirun (Open MPI) 1.6.5
The system is Ubuntu 14.04 on the Virtal Machine.
Any ideas why? Thanks!
mpi4py.get_config()
return compilers that are in the same path as your mpirun? – Permutationmpi4py.get_config()
returns{'mpicxx': '/usr/bin/mpicxx', 'mpif77': '/usr/bin/mpif77', 'mpicc': '/usr/bin/mpicc', 'mpif90': '/usr/bin/mpif90'}
But I tried the same on my localhost and get the same output (the same config), and at my localhost the code works. – Provoke$ which mpirun mpiexec /usr/bin/mpirun /usr/bin/mpiexec
– Provokempirun: /usr/bin/mpirun.mpich /usr/bin/mpirun /usr/bin/mpirun.openmpi /usr/bin/X11/mpirun.mpich /usr/bin/X11/mpirun /usr/bin/X11/mpirun.openmpi /usr/share/man/man1/mpirun.1.gz
mpiexec:/usr/bin/mpiexec.mpich /usr/bin/mpiexec.hydra /usr/bin/mpiexec /usr/bin/mpiexec.openmpi /usr/bin/X11/mpiexec.mpich /usr/bin/X11/mpiexec.hydra /usr/bin/X11/mpiexec /usr/bin/X11/mpiexec.openmpi /usr/share/man/man1/mpiexec.1.gz
Sorry for formatting, I'm just getting know how to use Stack Oerflow – Provoke