我在虚拟机上运行 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
我尝试使用 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
并来自 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
他们似乎没有得到通讯的等级和大小。什么会导致这种情况?如何解决?
mpiexec --version
mpiexec (OpenRTE) 1.6.5
mpirun --version
mpirun (Open MPI) 1.6.5
该系统是虚拟机上的 Ubuntu 14.04。
任何想法为什么?谢谢!