mpiexec和python mpi4py给出等级0和大小1

ziu*_*iuu 8 python mpi mpiexec mpi4py

我在虚拟机上运行python Hello World mpi4py代码时遇到问题.

hello.py代码是:

#!/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
Run Code Online (Sandbox Code Playgroud)

我试图用mpiexec和mpirun来运行它,但运行不好.输出:

$ 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
Run Code Online (Sandbox Code Playgroud)

从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
Run Code Online (Sandbox Code Playgroud)

他们似乎没有得到通讯的等级和大小.是什么导致这个?怎么解决?

mpiexec --version
mpiexec (OpenRTE) 1.6.5

mpirun --version
mpirun (Open MPI) 1.6.5
Run Code Online (Sandbox Code Playgroud)

该系统是Virtal Machine上的Ubuntu 14.04.

有什么想法吗?谢谢!

use*_*185 0

运行 python 模块时我遇到了同样的问题emcee。它会给我一个错误:

"ValueError: Tried to create an MPI pool, but there was only one MPI process available. 
Need at least two."
Run Code Online (Sandbox Code Playgroud)

我为我的特定集群找到的解决方案是使用不同的 MPI。我的代码适用于intel-mpiandmpich2但不适用于openmpi。对于这个系统,我所要做的就是切换 MPI。在我的PBS脚本中,我使用module load mpich2而不是module load openmpi. 在这种情况下mpiexec并且mpirun工作正常。