我在虚拟机上运行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 …Run Code Online (Sandbox Code Playgroud)