打开MPI – mpirun在简单程序上退出并出错

我最近在我的计算机上安装了OpenMPI,当我尝试运行一个简单的Hello World程序时,它会退出并出现下一个错误:

------------------------------------------------------- Primary job terminated normally, but 1 process returned a non-zero exit code.. Per user-direction, the job has been aborted. ------------------------------------------------------- 

这是该程序的源代码:

 #include  #include  int main(int argc, char *argv[]) { int size, rank; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); printf("Hello\n"); MPI_Finalize(); return 0; } 

这是我编译程序的方式:

 mpicc -o hello hello.c 

我用它执行它

 mpirun -np 2 hello 

它在编译时不会抛出任何错误,如果我运行./hello ,它运行正常。

请原谅我的英文,欢迎任何更正。

尝试:

 mpirun -x LD_PRELOAD=libmpi.so -np 2 hello 

如果可行,您可能在安装OpenMPI时遇到问题。 一个简单的解决方法是定义别名。 如果你使用bash,添加〜/ .bashrc

 alias mpirun='mpirun -x LD_PRELOAD=libmpi.so'