Open MPI - mpirun exits with error on simple program

谁都会走 提交于 2019-12-08 17:19:08

问题


I have recently installed OpenMPI on my computer and when I try to run a simple Hello World program, it exits with the next error:

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

This is the program's source code:

#include <mpi.h>
#include <stdio.h>

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;
}

This is how I compile the program:

mpicc -o hello hello.c

and I execute it with

mpirun -np 2 hello

It throws no errors on compilation, and if I run ./hello, it runs ok.

Excuse my english, any correction will be welcome.


回答1:


Try:

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

If it works, you probably have an issue with your OpenMPI installation. A simple workaround would be to define an alias. If ou use bash, add in ~/.bashrc:

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


来源:https://stackoverflow.com/questions/31330511/open-mpi-mpirun-exits-with-error-on-simple-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!