Discussion:
[OMPI users] Hello world Runtime error: Primary job terminated normally, but 1 process returned a non-zero exit code.
Pranav Sumanth
2017-05-22 10:33:23 UTC
Permalink
Hello All,

I'm able to successfully compile my code when I execute the make command. However, when I run the code as:

mpirun -np 4 test
The error generated is:

-------------------------------------------------------
Primary job terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

Process name: [[63067,1],2]
Exit code: 1
--------------------------------------------------------------------------
I have no multiple mpi installations so I don't expect there to be a problem.

I've been having trouble with my Hello World OpenMPI program. My main file is :

#include <iostream>
#include "mpi.h"

using namespace std;

int main(int argc, const char * argv[]) {


MPI_Init(NULL, NULL);

int size, rank;

MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

cout << "The number of spawned processes are " << size << "And this is the process " << rank;

MPI_Finalize();


return 0;

}
My makefile is:

# Compiler
CXX = mpic++

# Compiler flags
CFLAGS = -Wall -lm

# Header and Library Paths
INCLUDE = -I/usr/local/include -I/usr/local/lib -I..
LIBRARY_INCLUDE = -L/usr/local/lib
LIBRARIES = -l mpi

# the build target executable
TARGET = test

all: $(TARGET)

$(TARGET): main.cpp
$(CXX) $(CFLAGS) -o $(TARGET) main.cpp $(INCLUDE) $(LIBRARY_INCLUDE) $(LIBRARIES)


clean:
rm $(TARGET)
The output of: mpic++ --version is:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
And that for mpirun --version is:

mpirun (Open MPI) 2.1.1

Report bugs to http://www.open-mpi.org/community/help/
What could be causing the issue?


Thanks,
Best Regards,
Pranav
Gilles Gouaillardet
2017-05-22 13:58:11 UTC
Permalink
Hi,

what if you
mpirun -np 4 ./test

Cheers,

Gilles
Post by Pranav Sumanth
Hello All,
I'm able to successfully compile my code when I execute the make command.
mpirun -np 4 test
-------------------------------------------------------
Primary job terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
Process name: [[63067,1],2]
Exit code: 1
--------------------------------------------------------------------------
I have no multiple mpi installations so I don't expect there to be a problem.
#include <iostream>
#include "mpi.h"
using namespace std;
int main(int argc, const char * argv[]) {
MPI_Init(NULL, NULL);
int size, rank;
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
cout << "The number of spawned processes are " << size << "And this is the process " << rank;
MPI_Finalize();
return 0;
}
# Compiler
CXX = mpic++
# Compiler flags
CFLAGS = -Wall -lm
# Header and Library Paths
INCLUDE = -I/usr/local/include -I/usr/local/lib -I..
LIBRARY_INCLUDE = -L/usr/local/lib
LIBRARIES = -l mpi
# the build target executable
TARGET = test
all: $(TARGET)
$(TARGET): main.cpp
$(CXX) $(CFLAGS) -o $(TARGET) main.cpp $(INCLUDE) $(LIBRARY_INCLUDE) $(LIBRARIES)
rm $(TARGET)
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
mpirun (Open MPI) 2.1.1
Report bugs to http://www.open-mpi.org/community/help/
What could be causing the issue?
Thanks,
Best Regards,
Pranav
Jeff Squyres (jsquyres)
2017-05-22 16:07:02 UTC
Permalink
What Gilles suggested is probably the right answer.

There's a Linux executable named "test" already (e.g., /usr/bin/test) that is not an MPI application. When you didn't specify a path, mpirun probably found and ran that one instead.
Post by Gilles Gouaillardet
Hi,
what if you
mpirun -np 4 ./test
Cheers,
Gilles
Hello All,
mpirun -np 4 test
------------------------------
-------------------------
Primary job terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
------------------------------
-------------------------
------------------------------
------------------------------
--------------
mpirun detected that one or more processes exited with non-zero status, thus causing
Process name: [[63067,1],2]
Exit code: 1
------------------------------
------------------------------
--------------
I have no multiple mpi installations so I don't expect there to be a problem.
#include <iostream>
#include "mpi.h"
using namespace std;
int main(int argc, const char * argv[]) {
MPI_Init(NULL, NULL);
int size, rank;
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
cout << "The number of spawned processes are " << size << "And this is the process " << rank;
MPI_Finalize();
return 0;
}
# Compiler
CXX = mpic++
# Compiler flags
CFLAGS = -Wall -lm
# Header and Library Paths
INCLUDE = -I/usr/local/include -I/usr/local/lib -I..
LIBRARY_INCLUDE = -L/usr/local/lib
LIBRARIES = -l mpi
# the build target executable
TARGET = test
all: $(TARGET)
$(TARGET): main.cpp
$(CXX) $(CFLAGS) -o $(TARGET) main.cpp $(INCLUDE) $(LIBRARY_INCLUDE) $(LIBRARIES)
rm $(TARGET)
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/
include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/
Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/
bin
mpirun (Open MPI) 2.1.1
Report bugs to
http://www.open-mpi.org/community/help/
What could be causing the issue?
Thanks,
Best Regards,
Pranav
_______________________________________________
users mailing list
https://rfd.newmexicoconsortium.org/mailman/listinfo/users
--
Jeff Squyres
***@cisco.com
Pranav Sumanth
2017-05-22 18:38:13 UTC
Permalink
Dear Gilles and Jeff!

Thanks for your inputs. It fixed my problem.

Regards,
Pranav
Re: Hello world Runtime error: Primary job terminated
normally, but 1 process returned a non-zero exit code.
Loading...