【发布时间】:2014-10-19 16:18:06
【问题描述】:
我正在按照here 的说明进行操作。
发生的情况是,wait 或 communicate 立即返回,而不是等待 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