【问题标题】:Running mpirun with srun on multiple nodes gives a different communicator在多个节点上使用 srun 运行 mpirun 会提供不同的通信器
【发布时间】:2019-08-13 15:38:48
【问题描述】:

我正在使用来自 Here 的 hello world 示例,其中每个进程都在打印其进程名称及其 MPI_COMM_WORLD 等级 ID 和通信器大小。

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

int main(int argc, char** argv) {
    // Initialize the MPI environment
    MPI_Init(NULL, NULL);

    // Get the number of processes
    int world_size;
    MPI_Comm_size(MPI_COMM_WORLD, &world_size);

    // Get the rank of the process
    int world_rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

    // Get the name of the processor
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    int name_len;
    MPI_Get_processor_name(processor_name, &name_len);

    // Print off a hello world message
    printf("Hello world from processor %s, rank %d out of %d processors\n",
           processor_name, world_rank, world_size);

    // Finalize the MPI environment.
    MPI_Finalize();
}

我在 slurm 上以两种不同的方式运行此示例,一次使用 srun,一次使用 sbatch。

更准确地说:

(1)

srun -N 2 -n 2 mpirun ./a.out

(2)

sbatch testsimple.job

文件 testsimple.job 包含:

#!/bin/bash
#SBATCH -N 2
#SBATCH -n 2
mpirun ./a.out

问题是我不明白输出的差异,至少从我的理解来看,配置相似。

输出是:

(1)

Hello world from processor node1, rank 0 out of 2 processors
Hello world from processor node2, rank 1 out of 2 processors
Hello world from processor node2, rank 1 out of 2 processors
Hello world from processor node1, rank 0 out of 2 processors

(2)

Hello world from processor node1, rank 0 out of 2 processors
Hello world from processor node2, rank 1 out of 2 processors

输出 (2) 如我所料,但不是使用 srun 输出 (1)。 这里 srun 似乎在每个节点上精确地执行 mpirun 并且两次运行都不在同一个 MPI 应用程序中,因此 MPI_COMM_WORLD 通信器在两个节点上并不相同。而 sbatch 设法做到这一点。

我不认为这是故意的,所以我唯一的猜测是我对 slurm 的理解或我使用它的方式有问题。

我认为我需要为我的应用程序使用 srun,因为它有一个低级选项 --cpu_bind,而 sbatch 没有它。 我想我需要使用此选项手动执行 heterogeneous job allocation,并且 slurm 版本低于 17.11,遵循 this 指南。

我的问题是:

  • 您是否发现我在使用 slurm 或我对这两个命令应该做什么的理解上有明显的错误?还是您认为这可能与 slurm 配置有关(我对此一无所知,我不是管理员)?

  • 如果问题不明显,您还有其他建议使用 sbatch 处理异构作业吗?

感谢您的阅读和您提供的任何帮助!

【问题讨论】:

  • 如果您的 MPI 库中内置了 pmi 支持,那么只需 srun ./a.out

标签: mpi slurm


【解决方案1】:

运行srun -N 2 -n 2 mpirun ./a.out导致Slurm在两个节点上分配两个任务,并让每个任务运行mpirun ./a.out,导致最终创建四个进程。

您应该只运行srun -N 2 -n 2 ./a.out。如果 Slurm 和您的 MPI 库都配置正确,它应该可以正常工作。

【讨论】:

    猜你喜欢
    • 2022-11-05
    • 2018-12-29
    • 2012-04-17
    • 2015-10-29
    • 1970-01-01
    • 2020-09-18
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多