【发布时间】:2019-03-21 15:58:23
【问题描述】:
我正在尝试使用 Slurm 操作的集群来运行 LS-Dyna(一个有限元模拟程序我的集群上可用的许可证数量有限)。我正在尝试编写我的批处理脚本,这样我就不会因为这个许可证限制而浪费处理时间(以及在运行“队列”命令时提高易读性),但我在完成这项工作时遇到了麻烦。
我想在各种 FEM 网格中运行相同的 Bash 脚本,我将每个网格组织到不同的子文件夹中。
鉴于我的集群上的这个文件夹结构...
cluster root
|
...
|
|-+ my scratch space's root
|
|-+ this project
|
|--+ lat_-5mm
| |- runCurrentLine.bash
| |- other files
|
|--+ lat_-4.75mm
| |- runCurrentLine.bash
| |- other files
|
|--+ lat_-4.5mm
| |- runCurrentLine.bash
| |- other files
|
...
|
|--+ lat_5mm
| |- runCurrentLine.bash
| |- other files
|
|
|-sendDynaRuns.bash
|-other dependencies
...我正在尝试通过在我的登录节点中运行以下脚本来在每个文件夹中提交“runCurrentLine.bash”。
#!/bin/bash
iter=0
for foldernow in */; do
# change to subdirectory for current line iteration
cd "./${foldernow}";
# make Slurm and user happy
echo "sending LS Dyna simulation for ${pos}mm line..."
sleep 1
# first line only: send batch, and get job ID
if [ "${iter}" == 0 ];then
# send the batch...
jobID=$(sbatch -J "Dyna" --array="${iter}"%15 runCurrentLine.bash)
# ...ensure that Slurm's output shows on console (which includes the job ID)...
echo "${jobID}"
# ...and extract the job ID and save as a variable
jobID=$(echo "${jobID}" | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
# subsequent lines: add current line to job array
else
scontrol update --jobid="${jobID}" --array="${iter}"%15 runCurrentLine.bash
fi
# prepare to move onto next position
iter=$((iter+1))
cd ../
done
此设置正确发送第一行的批处理作业,在 -0.25mm*。但是,从第二行开始,它似乎并没有做同样的事情......这就是我最终在我的控制台上得到的:
*:我希望“lat_xmm”文件夹按数字顺序排列,但 Unix 似乎无法识别
$ ./sendDynaRuns.bash
sending LS Dyna simulation for -0.25mm line...
Submitted batch job 1081040
sending LS Dyna simulation for 0.25mm line...
sbatch: error: Batch job submission failed: Invalid job id specified
sending LS Dyna simulation for -0.5mm line...
sbatch: error: Batch job submission failed: Invalid job id specified
我知道如果我手动将 runCurrentLine.bash 作为批处理发送它运行得很好(它会在我在文件中指定的时间限制内运行到完成,主要是因为它不必与其他行竞争 open许可证)。我应该怎么做才能让我的代码正常工作?
提前谢谢你!
【问题讨论】:
-
如果您要发送作业数组,则必须在一次提交中发送所有数组。您不能将作业添加到现有阵列。如果您需要独立启动作业,则应使用常规作业(但随后您将无法控制并行运行的作业数量),但您需要将许可证作为负责的资源才能请求并让 SLURM 照顾他们。
-
我看到您尝试多次发送相同的脚本,只是更改了阵列 ID 和文件夹。您应该避免文件夹更改并在脚本中执行该更改,从作业数组 ID 中确定哪个是正确的文件夹。然后,您要查找的命令比那些乱七八糟的命令要容易得多:
sbatch -J "Dyna" --array="0-${nFolders}"%15 runCurrentLine.bash