Mpiexec and python mpi4py gives rank 0 and size 1

I had a problem running python Hello World mpi4py python code in a virtual machine.

Hello.py code:

#!/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 tried to launch it using mpiexec and mpirun, but it does not work very well. 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 don't seem to get the title and size of comms. What can cause this? How to solve it?

mpiexec --version
mpiexec (OpenRTE) 1.6.5

mpirun --version
mpirun (Open MPI) 1.6.5

Ubuntu 14.04 system on Virtal Machine.

Any ideas why? Thank!

+7
source share
2 answers

I had the same problem when running the python module emcee. This would give me an error:

"ValueError: Tried to create an MPI pool, but there was only one MPI process available. 
Need at least two."

, , MPI. intel-mpi mpich2, openmpi. , , MPI. PBS script module load mpich2 module load openmpi. mpiexec mpirun .

0

C, , mpirun MPI, mpi4py , mpi4py .

, , Python, , mpi4py conda, MPI conda - , which mpirun conda .

, conda remove mpi4py pip install mpi4py, , , mpi4py MPI conda .

0

All Articles