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

2024-04-29 11:59:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我在虚拟机上运行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

系统是Virtal机器上的Ubuntu 14.04。

你知道为什么吗?谢谢!


Tags: of代码frompyhelloworldsizeget