迭代循环的 slurm 作业脚本

问题描述 投票:0回答:1

我使用这样的 bash 脚本,

for i in  0 1 2 3 4 5 do  

export OMP_NUM_THREADS=$((2 **i)) 
&& ./debug > ./logs/112500/exp$1/log-$((2 **i)).txt    

done

出于经验目的,现在我需要运行此脚本 32 次。我有一个如下所示的 slurm 作业脚本,但它以一种奇怪的方式执行。为了保持与上面相同的语义,我希望 srun 运行我的二进制文件并完成,然后继续 2 个线程,依此类推,直到第二个实验开始。所以每个实验一次运行。在每个实验中,每个 srun 也需要同时运行。

然而真正发生的是,32 个实验按顺序运行,但每次只执行第一个 srun,线程数为 1,并创建其日志文件 (log-1.txt)。当我在 srun 之间插入 echo 时,它们会被打印出来,但不会打印 srun bash -c echos。在第一个 srun 之后的其他 srun 根本没有被执行,尽管实验循环迭代了 32。我想知道为什么会发生这种情况并寻找解决方案。

`#!/bin/bash`
`#SBATCH -p cs`
`#SBATCH -e %j.err`
`#SBATCH --time=05:00`
`#SBATCH --output=slurm-%j.out`

`#executable`

`for I in $(seq 32);`
`do`
`mkdir ./logs/112500/exp$I`
`export OMP_NUM_THREADS=1`
`echo "Launching command for ./logs/112500/exp$I/log-1.txt"`
`srun --nodes=1 --ntasks=1 --cpus-per-task=1  bash -c "./debug > ./logs/112500/exp$I/log-1.txt"`
`export OMP_NUM_THREADS=2`
`srun --nodes=1 --ntasks=1 --cpus-per-task=2  bash -c "./debug > ./logs/112500/exp$I/log-2.txt"`
`export OMP_NUM_THREADS=4`
`srun --nodes=1 --ntasks=1 --cpus-per-task=4  bash -c "./debug > ./logs/112500/exp$I/log-4.txt"`
`export OMP_NUM_THREADS=8`
`srun --nodes=1 --ntasks=1 --cpus-per-task=8 bash -c  "./debug > ./logs/112500/exp$I/log-8.txt"`
`export OMP_NUM_THREADS=16`
`srun --nodes=1 --ntasks=1 --cpus-per-task=16 bash -c "./debug > ./logs/112500/exp$I/log-16.txt"`
`export OMP_NUM_THREADS=32`
`srun --nodes=1 --ntasks=1 --cpus-per-task=32 bash -c "./debug > ./logs/112500/exp$I/log-32.txt"`
`done`

slurm 作业脚本,顺序 srun,只有一个 srun 执行

bash parallel-processing openmp slurm
1个回答
0
投票

好了,刚刚破案了。缺少有关资源分配的标头信息给以下 srun 带来了一些麻烦,因为他们想要分配比默认 (ntasks=1) 资源更多的资源。

© www.soinside.com 2019 - 2024. All rights reserved.