【问题标题】:MPI_Barrier doesn't work properly in UbuntuMPI_Barrier 在 Ubuntu 中无法正常工作
【发布时间】:2023-04-07 06:11:01
【问题描述】:

我是使用 MPI 的初学者。这里我写了一个非常简单的程序来测试 MPI 是否可以运行。这是我的hello.c:

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

int main(int argc, char *argv[]) {
  int numprocs, rank, namelen;
  char processor_name[MPI_MAX_PROCESSOR_NAME];

  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Get_processor_name(processor_name, &namelen);
  MPI_Barrier(MPI_COMM_WORLD);
  printf("Process %d on %s out of %d\n", rank, processor_name, numprocs);

  MPI_Finalize();
}

我用to node来测试,hostfile是:node1 node2

所以我有两台机器,名称分别为 node1 和 node2。我可以不用密码互相ssh。

我通过输入:mpirun -np 2 -f hostfile ./hello 来启动程序。

可执行的 hello 位于两台机器的同一目录中。

然后在我运行之后,我得到一个错误:

PMPI_Barrier 中的致命错误:其他 MPI 错误,错误堆栈: PMPI_Barrier(425).......: MPI_Barrier(MPI_COMM_WORLD) 失败 MPIR_Barrier_impl(331)....:集体失败 MPIR_Barrier_impl(313)....: MPIR_Barrier_intra(83)....: dequeue_and_set_error(596): 等级为 0 的通信错误致命 PMPI_Barrier 中的错误:其他 MPI 错误,错误堆栈: PMPI_Barrier(425).......: MPI_Barrier(MPI_COMM_WORLD) 失败 MPIR_Barrier_impl(331)....:集体失败 MPIR_Barrier_impl(313)....: MPIR_Barrier_intra(83)....: dequeue_and_set_error(596): 等级 1 的通信错误

如果我注释掉 MPI_Barrier(),它可以正常工作。机器之间的通讯好像有问题?或者我没有正确安装openmpi?有什么想法吗?

我使用的是 Ubuntu 12.10

我得到了一些提示:这在 MPICH2 中效果不佳,如果我使用 openmpi,那么它可以工作。我只是通过 sudo apt-get install mpich2 安装了 MPICH。我错过了什么吗? mpich2的大小比openmpi小很多

【问题讨论】:

  • 1) hostfile 中的计算机名需要分行,是这样吗? 2) 如果您注释 MPI_Barrier 行,程序输出是什么? 3) 你是如何编译程序的?
  • @RafaelReiter 是对的;这通常是配置问题。两个节点之间的无密码 ssh 是必要的,但 MPI 通常还需要打开广泛的端口,因此请检查任何防火墙、iptables 规则等:wiki.mpich.org/mpich/index.php/…
  • 我可以通过openmpi使用这个程序,所以肯定它与网络无关。我的主机文件位于不同的行中。
  • 我通过 mpicc -o hello hello.c 编译

标签: mpi


【解决方案1】:

在 /etc/hosts 中,一些 Linux 发行版的较新版本在文件顶部添加以下类型的行:

127.0.0.1 localhost
127.0.0.1 [hostname]

这应该改变,以便主机名行包含您的实际 IP 地址。如果您不进行此更改并出现以下错误,则 MPI hydra 进程将中止:

Fatal error in PMPI_Barrier: Other MPI error, error stack:
PMPI_Barrier(425)...........: MPI_Barrier(MPI_COMM_WORLD) failed
MPIR_Barrier_impl(292)......: 
MPIR_Barrier_or_coll_fn(121): 
MPIR_Barrier_intra(83)......: 
dequeue_and_set_error(596)..: Communication error with rank 0

【讨论】:

    猜你喜欢
    • 2012-01-04
    • 2015-04-13
    • 1970-01-01
    • 2022-12-17
    • 2021-04-04
    • 1970-01-01
    • 2012-11-08
    • 2021-11-02
    • 2014-12-11
    相关资源
    最近更新 更多