我刚刚开始使用MPI。我有一个示例代码在mpi.scatter
调用失败(它挂在5节点的情况下,我必须ctrl-c退出)。
我的配置如下:
安装完所有上述内容后,所有节点的hello-world
测试工作正常,五节点cpi
(calc pi)测试也是如此。但分散测试失败了,有五个节点:
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
data = None
if rank == 0:
data = [1] #... this is changed to ‘data = [1, 2, 3, 4, 5] for the 5- node case
print 'test 1: rank 0 data load', data
else:
data = None
print 'entering scatter from rank: ', rank
data = comm.scatter(data, root=0)
assert data == (rank+1)**2
print 'rank: ', rank, ' scatter'
data += 1
print 'entering gather from rank: ', rank
data = comm.gather(data,root=0)
print 'rank: ', rank, ' gather'
单节点案例运行并生成:
pi @ aor00:〜/ mpi4py $ mpirun.openmpi -np 1 -machinefile / home / pi / mpi_testing / machinefile python /home/pi/Desktop/sct/scattertest-1node.py
测试1:排名0数据加载[1]
从排名输入分散:0
排名:0分散
从排名进入聚集:0
排名:0聚集
但是五个节点运行挂起,我用ctrl-c
中止它pi @ aor00:〜/ mpi4py $ mpirun.openmpi -np 5 -machinefile / home / pi / mpi_testing / machinefile python /home/pi/Desktop/sct/scattertest.py
测试1:排名0数据加载[1,2,3,4,5]
从排名输入分散:0
从排名进入分散:2
从排名进入分散:1
从排名进入分散:4
从排名进入分散:3
^ Cmpirun.openmpi:杀人工作......