这是我的脚本和python代码。
钱猫走
while true
do
echo "------->"
python3 -m mpi4py ./go.py
echo "<------"
done这段代码在循环中运行python go.py。
$ cat go.py
import mpi4py.MPI as MPI
print( "######", MPI.Is_initialized())
comm = MPI.COMM_WORLD
comm_rank = comm.Get_rank()
comm_size = comm.Get_size()
# point to point communication
data_send = [comm_rank]*5
comm.send(data_send,dest=(comm_rank+1)%comm_size)
data_recv =comm.recv(source=(comm_rank-1)%comm_size)
print("my rank is %d, and Ireceived:" % comm_rank)
print( data_recv )
MPI.Finalize()
print( "######", MPI.Is_finalized())这个python代码就是打印出来的。
在我运行这个go脚本之后,go.py执行并退出,当go.py再次执行时,它被卡住了。
$ mpirun --mca orte_base_help_aggregate 0 -np 2 sh ./go
------->
------->
--------------------------------------------------------------------------
[[27909,1],1]: A high-performance Open MPI point-to-point messaging module
was unable to find any relevant network interfaces:
Module: OpenFabrics (openib)
Host: myvm20
Another transport will be used instead, although this may result in
lower performance.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
[[27909,1],0]: A high-performance Open MPI point-to-point messaging module
was unable to find any relevant network interfaces:
Module: OpenFabrics (openib)
Host: myvm20
Another transport will be used instead, although this may result in
lower performance.
--------------------------------------------------------------------------
###### True
###### True
my rank is 0, and Ireceived:
[1, 1, 1, 1, 1]
my rank is 1, and Ireceived:
[0, 0, 0, 0, 0]
###### True
###### True
<------
------->
<------
------->
--------------------------------------------------------------------------
[[27909,1],0]: A high-performance Open MPI point-to-point messaging module
was unable to find any relevant network interfaces:
Module: OpenFabrics (openib)
Host: myvm20
Another transport will be used instead, although this may result in
lower performance.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
[[27909,1],1]: A high-performance Open MPI point-to-point messaging module
was unable to find any relevant network interfaces:
Module: OpenFabrics (openib)
Host: myvm20
Another transport will be used instead, although this may result in
lower performance.
--------------------------------------------------------------------------永远冻僵。
为什么它会卡住,我怎样才能继续这个脚本?
顺便说一句:我有两种工作要做,一是坚持工作,二是完成工作,二是辞职。所以我不能按以下方式运行:
while true
do
echo "------->"
mpirun -np 2 A : -np 2 B
echo "<------"
done还有别的办法吗?
发布于 2017-11-16 07:46:51
长话短说,你不能那么做。
下面是你应该做的事情
while true
do
echo "------->"
mpirun --mca orte_base_help_aggregate 0 -np 2 python3 -m mpi4py ./go.py
echo "<------"
donehttps://stackoverflow.com/questions/47320846
复制相似问题