【发布时间】:2019-04-29 14:02:29
【问题描述】:
我正在尝试使用 mpi4py 中的 MPI 模块在 python (3.7.0) 中初始化 MPI,但是当我尝试以下操作时它会无限期挂起:
mpirun -n 4 python -c "from mpi4py import MPI"
这行得通:
python -c "from mpi4py import MPI"
但这不是:
mpirun -n 1 python -c "from mpi4py import MPI"
我也试过
import mpi4py
mpi4py.rc.initialize = False
from mpi4py import MPI
MPI.Init()
但是当使用 mpirun 执行时,它会挂在 MPI.Init() 步骤。
我的 mpirun 版本是 1.10.7,mpi4py 版本是 3.0.1,我使用的是 macOS Mojave (10.14.3)。
编辑(回应@jcgiret):
我还尝试了以下方法:
mpirun -n 4 python -c "print('Before'); from mpi4py import MPI; print('After')"
只为得到
Before
Before
Before
Before
作为输出
【问题讨论】:
-
您是否尝试过在 ls 等虚拟命令上使用 mpirun? mpirun -n 2 ls 是否挂起?另外,您可以尝试使用 -np 而不是 -n 吗?
-
我认为以下内容可以澄清问题。这段代码的输出``` mpirun -n 4 python -c "print('Before'); from mpi4py import MPI; print('After')" ```是``` Before Before Before Before ```