1

如果我在导入 MPI 的 python 脚本中启动对 mpiexec 的子进程调用,则调用失败。例如调用时python test.py, wheretest.py有如下代码

import subprocess

if __name__ == "__main__":
    subprocess.check_call(["mpiexec","-n","2", "echo", "hello world!"])

输出是

hello world!
hello world!

但是什么test.py时候

import subprocess
from mpi4py import MPI
from mpi4py.futures import MPICommExecutor


if __name__ == "__main__":
    subprocess.check_call(["mpiexec","-n","2", "echo", "hello world!"])

输出是

Traceback (most recent call last):
  File "test.py", line 10, in <module>
    subprocess.check_call(["mpiexec","-n","2", "echo", "hello world!"])
  File "anaconda3/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['mpiexec', '-n', '2', 'echo', 'hello world!']' returned non-zero exit status 1.

谁能解释为什么会这样?

4

0 回答 0