我可以递归地致电sbatch吗?
我想运行一个运行并创建检查点文件的程序。然后,我想运行几个从该检查点开始的变体配置。
例如,如果我运行:
sbatch -n 1 -t 12:00:00 --mem=16g program.sh
和program.sh
看起来像这样:
#!/bin/sh
./set_checkpoint
sbatch -n 1 -t 12:00:00 --mem=16g cpt_restore_config1.sh
sbatch -n 1 -t 12:00:00 --mem=16g cpt_restore_config2.sh
sbatch -n 1 -t 12:00:00 --mem=16g cpt_restore_config3.sh
sbatch -n 1 -t 12:00:00 --mem=16g cpt_restore_config4.sh
这是否实现了所需的效果?
I want to run a program that runs and creates a checkpoint file. Then I want to run several variant configurations that all start from that checkpoint.
For example, if I run:
sbatch -n 1 -t 12:00:00 --mem=16g program.sh
And program.sh
looks like this:
#!/bin/sh
./set_checkpoint
sbatch -n 1 -t 12:00:00 --mem=16g cpt_restore_config1.sh
sbatch -n 1 -t 12:00:00 --mem=16g cpt_restore_config2.sh
sbatch -n 1 -t 12:00:00 --mem=16g cpt_restore_config3.sh
sbatch -n 1 -t 12:00:00 --mem=16g cpt_restore_config4.sh
Does this implement the desired effect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,这不需要。您可以在主要作业脚本中分配所需的所有资源,并使用
srun
将资源用于特定任务。这是一个基本示例。请注意,我们分配了8个CPU,并将4用于每个任务。在这里,两个
srun
任务将顺序运行。为了使其并行运行,您可以使用此技巧。请记住,这在几种情况下可能无法使用。我建议使用logger并将
stdout
和stderr
重定向到文件。 这里是一个简单的示例。另外,如果您的任务使用具有不同参数集的单个文件,我建议使用参数解析。在Python中,我通常使用 hydra /joblib_launcher/“ rel =“ nofollow noreferrer”> joblib 扩展。它为您提供了平行的功能。
In general this is not needed. You can allocate all the resources you want in main job script and use resources for specific task with
srun
. Here is a basic example.Note that we allocated 8 CPUs and used 4 for each task. Here, the two
srun
tasks will run sequentially. To make it run in parallel, you can use this trick.Just keep in mind this might not work in several cases. I would suggest using a logger and redirect the
STDOUT
andSTDERR
to a file. Here is a simple example.Alternatively, if your tasks are using a single file with different set of parameters, I suggest using argument parsing. In Python, I generally use Hydra's joblib extension. It gives you parallelism capability out of the box.