13

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.

fenusa0
  • 146
  • 1
  • 1
  • 5
  • 5
    Make sure you are using the same MPI distribution (OpenMPI, MPICH, MVAPICH) and version for compiling with `mpicc` and running the program `mpirun`. Your error could very well be caused my a mismatch in version and or distribution. – Patrick Jul 10 '15 at 00:34
  • I've downloaded and installed the last stable version of OpenMPI. Before the install, I had no version of MPI installed – fenusa0 Jul 10 '15 at 02:05
  • check the return values. –  Dec 12 '15 at 04:30
  • You mention that you used the last stable version but which version is that? – Harald Jan 19 '16 at 05:47
  • [This](https://users.open-mpi.narkive.com/YefqHf8v/ompi-users-hello-world-runtime-error-primary-job-terminated-normally-but-1-process-returned-a-non) seems to be the same error. The answer below with `./` should work. – Albert Jun 29 '20 at 08:47

2 Answers2

4

you have to ./ the executable name try this, mpirun -np 2 ./hello

user13109888
  • 49
  • 1
  • 2
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' 
jyvet
  • 2,021
  • 15
  • 22