How To Run MPI Python Script across multiple nodes on Slurm cluster? Error: Warning: can't run 1 processes on 2 nodes, setting nnodes to 1

How To Run MPI Python Script across multiple nodes on Slurm cluster? Error: Warning: can't run 1 processes on 2 nodes, setting nnodes to 1

我正在 运行在 Slurm 集群上编写一个可以从并行处理中获益的脚本,所以我正在尝试实施 MPI。但是,它似乎不允许我在多个节点上进行 运行 处理。我不知道这是否通常是自动完成的,但是每当我在提交的批处理文件中设置 --nodes=2 时,我都会收到错误消息,"Warning: can't run 1 processes on 2 nodes, setting nnodes to 1."

我一直试图让它与一个简单的 Hello World 脚本一起工作,但仍然 运行 出现上述错误。当我 运行 MPI 脚本时,我在选项中添加了 --oversubscribe ,但仍然出现此错误。

    #SBATCH --job-name=a_test
    #SBATCH --mail-type=ALL
    #SBATCH --ntasks=1
    #SBATCH --cpu-freq=high
    #SBATCH --nodes=2
    #SBATCH --cpus-per-task=2
    #SBATCH --mem-per-cpu=1gb
    #SBATCH --mem-bind=verbose,local
    #SBATCH --time=01:00:00
    #SBATCH --output=out_%x.log

    module load python/3.6.2
    mpirun -np 4 --oversubscribe python par_PyScript2.py
```bash

I still get the expected output, but only after the error message "Warning: can't run 1 processes on 2 nodes, setting nnodes to 1." I'm worried that without being able to run on multiple nodes, my actual script will be a lot slower.

警告的原因是这一行:

#SBATCH --ntasks=1

在请求 2 个节点之前,您指定要 运行 只有 1 个 mpi 进程。

--ntasks 将进程数设置为 run/ranks 以在您的案例中使用。然后你用等效的 -n 覆盖它,这就是你看到结果的原因。

供您参考,这是我 运行 在我的系统上的脚本,

#!/bin/bash

#SBATCH -C knl 
#SBATCH -q regular
#SBATCH -t 00:10:00

#SBATCH --nodes=2

module load python3

START_TIME=$SECONDS

srun -n 4 python mpi_py.py >& py_${SLURM_JOB_ID}.log

ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo $ELAPSED_TIME

性能说明:

  • 如果可能,运行 将您的代码放在同一节点上会更快。节点间通信比节点内通信慢,它可能会慢一点,但也可能慢得多,这取决于集群架构等因素。
  • 参考您的集群设置建议。例如,在我的脚本中,我应该向该脚本添加某些 slurm 选项——特别是 -ccpu_bind=(更多 here)。