【问题标题】:Not able to start mpirun with subprocess.Popen无法使用 subprocess.Popen 启动 mpirun
【发布时间】:2014-10-19 16:18:06
【问题描述】:

我正在按照here 的说明进行操作。

发生的情况是,waitcommunicate 立即返回,而不是等待 mpi 进程完成。我在我的 python 应用程序的一个单独的线程中执行此操作。当我在 python shell 中以交互方式执行此操作时,它似乎有时会起作用。也许我必须在Popen 之后和wait/communicate 之前等待?

我打电话给Popen,如下:

mpicmd = 'mpirun -n 2 --hostfile hostfile ' + executable + ' ' + mpiArgs
mpirun = subprocess.Popen(mpicmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = mpirun.communicate()

当我从我的程序运行 mpirun 时,我得到:

--------------------------------------------------------------------------
There are no allocated resources for the application 
  rttl
that match the requested mapping:
  hostfile

Verify that you have mapped the allocated resources properly using the 
--host or --hostfile specification.

当我以交互方式(在同一目录中)执行此操作时,它可以工作。

也试过了:

mpirun = subprocess.Popen(['mpirun', '-n', '2', '--hostfile', 'hostfile', 'rttl', '10000'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

得到了同样的结果。

【问题讨论】:

  • 也许您可以提供更多细节(一些代码行?)。到目前为止,您所描述的似乎效果很好。 wait/communicate 正在阻塞并等待进程终止。
  • 我添加了更多详细信息,请参阅编辑。
  • 我会检查两个版本是否真的在同一个目录中运行。也许将ls -l; 添加到mpicmd。并检查$PATH$LD_LIBRARY_PATH 在两个版本中是否相同。

标签: python subprocess mpi pipe


【解决方案1】:

我刚刚遇到了同样的问题。我正在将我的主机文件的内容写入这样的文件:

myfile = open("hostfile", "w")
myfile.write("localhost")

然后我调用了 MPI 命令。问题是我忘记了 myfile.close() 命令...在我的 MPI 命令为我修复它之前添加它。

我知道这是一个旧帖子,但也许有人会遇到同样的问题

【讨论】:

  • 这很有帮助,解决了我的问题。添加.close() 将文件写入磁盘。新年快乐。 :)
猜你喜欢
  • 1970-01-01
  • 2020-01-19
  • 2014-09-02
  • 2013-08-18
  • 2020-12-15
  • 2018-07-27
  • 2019-12-18
  • 2015-03-21
  • 2011-08-01
相关资源
最近更新 更多