【问题标题】:mpi4py MPI.init() hangs indefinitelympi4py MPI.init() 无限期挂起
【发布时间】: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 "p​​rint('Before'); from mpi4py import MPI; print('After')" ```是``` Before Before Before Before ```

标签: macos python


【解决方案1】:

我通过安装 Miniconda 并使用包的 conda-forge 版本 (3.0.1) 设法解决了这个问题:

conda install -c conda-forge mpi4py

注意:它仍然不适用于 anaconda 版本 (2.0.0)

【讨论】:

    猜你喜欢
    • 2017-06-29
    • 2011-05-07
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-29
    • 2019-08-01
    • 1970-01-01
    相关资源
    最近更新 更多