【问题标题】:how to set number of task per node in slurm based on the parameter that I passed it to my program?如何根据我传递给程序的参数在 slurm 中设置每个节点的任务数?
【发布时间】:2016-03-30 12:41:53
【问题描述】:

我想将每个节点的任务数设置为 slurm 中的变量,例如:#SBATCH --ntasks-per-node=s*2; (s 是每个节点的套接字数,我将它作为参数传递给我的程序)。代码如下: test.c 文件的一部分:

if (argc < 3)
{
fprintf(stderr, "Usage: mpiexec program <#sockets>\n");
exit(1);
}
s = atoi(argv[1]);

bash 脚本(slurm):

#!/bin/bash
#SBATCH --job-name=test
#SBATCH --time=00:30:00
#SBATCH --account=1234
#SBATCH --output=./test.out
#SBATCH --nodes=4
#SBATCH --mem-per-cpu=3900M
#SBATCH --ntasks-per-node=s*2     ???  
#SBATCH --exclusive

source /cluster/bin/jobsetup 
module load intel/2015.3
module load openmpi.intel/1.8.6

cd ~/filedir
mpirun --map-by ppr:2:socket --report-bindings ./test 4 > ./test

如果我将 ntasks-per-node 设置为 8 之类的固定数量,它可以正常工作。但是如何根据传递给程序的参数来设置它呢? 如有任何帮助,我将不胜感激。

【问题讨论】:

    标签: c mpi slurm


    【解决方案1】:

    这是不可能的。一旦你的程序运行起来,SLURM 已经不得不修复每个节点的任务数。这是运行程序所必需的。

    但是,您可以扭转这种局面:在 SLURM 中设置每个节点的任务数并在程序中读取它。为此,SLURM 提供了许多环境变量。您可以使用getenv 阅读SLURM_STEP_TASKS_PER_NODE。但是您需要考虑,这可能不是单个整数,而是因节点而异。如果所有节点都相同,则对于两个节点,每个节点有 8 个核心,它将具有8(x2) 的形式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-15
      • 2017-06-28
      • 2018-10-19
      • 1970-01-01
      • 2021-08-02
      • 2019-11-01
      • 1970-01-01
      • 2022-07-28
      相关资源
      最近更新 更多