OpenMPI运行时错误:Hello World

时间:2017-05-21 18:25:35

标签: openmpi

我执行make命令时能够成功编译代码。但是,当我运行代码时:

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
the job to be terminated. The first process to do so was:

  Process name: [[63067,1],2]
  Exit code:    1
--------------------------------------------------------------------------

我没有多个mpi安装,所以我不希望出现问题。

我的Hello World OpenMPI计划遇到了问题。我的主要文件是:

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

}

我的makefile是:

# 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)

mpic++ --version的输出是:

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 --version的内容是:

mpirun (Open MPI) 2.1.1

Report bugs to http://www.open-mpi.org/community/help/

可能导致此问题的原因是什么?

1 个答案:

答案 0 :(得分:0)

现在已经解决了。事实证明我必须用

执行
softmax_cross_entropy_with_logits

参考:users-request@lists.open-mpi.org