OpenMPI代码在命令行上运行,但不是通过python子进程或shell脚本运行

时间:2013-11-02 15:09:43

标签: shell python-2.7 subprocess mpi openmpi

我正在尝试使用KVM在虚拟群集上运行MPI。 使用以下命令在终端中运行时,我的OpenMPI代码运行正常:

mpiuser@niru:~$ mpirun -n 5 -hostfile /home/mpiuser/hosts /home/mpiuser/hello

然而,当我运行我的python脚本时,使用

$sudo python test.py 

test.py:

import subprocess
p=subprocess.Popen(['mpirun -n 5 -hostfile /home/mpiuser/hosts /home/mpiuser/hello'],shell=True)

我收到错误:

 ssh: connect to host test0 port 22: No route to host
ssh: connect to host test1 port 22: No route to host
--------------------------------------------------------------------------
A daemon (pid 6608) died unexpectedly with status 255 while attempting
to launch so we are aborting.

There may be more information reported by the environment (see above).

This may be because the daemon was unable to find all the needed shared
libraries on the remote node. You may set your LD_LIBRARY_PATH to have the
location of the shared libraries on the remote nodes and this will
automatically be forwarded to the remote nodes.

所以我尝试使用shell脚本运行命令,但是我得到了同样的错误。

sudo sh ./launch.sh

launch.sh:

 mpirun -n 5 -hostfile /home/mpiuser/hosts /home/mpiuser/hello

我也尝试在我的计算机上导出LD_LIBRARY_PATH:

  export LD_LIBRARY_PATH=/usr/lib/openmpi/lib/openmpi

为什么mpirun在命令行中工作而不是通过Python或Shell脚本?请帮忙!


更新:我的〜/ .ssh / config文件的内容是:

Host test0 
Hostname 192.168.122.98
User mpiuser
PubKeyAuthentication yes
IdentityFile /home/mpiuser/cloudKey

Host test1
Hostname 192.168.122.195
User mpiuser
PubKeyAuthentication yes
IdentityFile /home/mpiuser/cloudKey

0 个答案:

没有答案