如何理解SLURM文档中的“job”、“task”和“step”这些术语?
据我了解,一个作业可以包含多个任务和步骤,但即使是这样,任务和步骤之间的关系仍不清楚。
通过示例展示作业/任务/步骤的完整复杂性将会很有帮助。
如何理解SLURM文档中的“job”、“task”和“step”这些术语?
据我了解,一个作业可以包含多个任务和步骤,但即使是这样,任务和步骤之间的关系仍不清楚。
通过示例展示作业/任务/步骤的完整复杂性将会很有帮助。
工作由一个或多个步骤组成,每个步骤都包含一个或多个任务,每个任务使用一个或多个CPU。
通常使用sbatch
命令创建作业,使用srun
命令创建步骤,在作业级别使用--ntasks
或--ntasks-per-node
请求任务,在步骤级别使用--ntasks
。使用--cpus-per-task
为每个任务请求CPU。请注意,使用sbatch
提交的作业有一个隐式步骤;Bash脚本本身。
假设有如下假想作业:
#SBATCH --nodes 8
#SBATCH --tasks-per-node 8
# The job requests 64 CPUs, on 8 nodes.
# First step, with a sub-allocation of 8 tasks (one per node) to create a tmp dir.
# No need for more than one task per node, but it has to run on every node
srun --nodes 8 --ntasks 8 mkdir -p /tmp/$USER/$SLURM_JOBID
# Second step with the full allocation (64 tasks) to run an MPI
# program on some data to produce some output.
srun process.mpi <input.dat >output.txt
# Third step with a sub allocation of 48 tasks (because for instance
# that program does not scale as well) to post-process the output and
# extract meaningful information
srun --ntasks 48 --nodes 6 --exclusive postprocess.mpi <output.txt >result.txt &
# Fourth step with a sub-allocation on a single node
# to compress the raw output. This step runs at the same time as
# the previous one thanks to the ampersand `&`
srun --ntasks 12 --nodes 1 --exclusive compress.mpi output.txt &
wait
创建了四个步骤,因此该作业的会计信息将有5行;每个步骤一个加上一个用于Bash脚本本身。
wait
命令?如果接下来没有后续步骤需要等待之前的步骤全部完成才能执行,我可以理解在wait
命令之后还有其他步骤时需要加上它,但是如果它是脚本中的最后一条命令,我不明白它的目的是什么。换句话说,如果省略掉末尾的wait
命令会发生什么? - kjowait
命令用于确保带有&
符号(步骤 3 和 4)的两个srun
命令在作业被认为完成并终止之前已经完成。如果没有这个命令,脚本会在步骤未完成时终止;此时 Slurm 将认为作业已完成,并杀死所有仍在运行的步骤。 - damienfrancois