如果第一个命令未分配,则通过 slurm 调度程序暂停 os.system 命令

发布于 2025-01-16 00:07:21 字数 413 浏览 4 评论 0原文

我在多节点集群上多次运行脚本,并且该脚本在集群上按顺序处理数据。这是代码:

import os
os.system("srun -p rs2 --mem-per-cpu 200G -t 7-23:00:00 python3 /home/usr/Sim/sim.py aok; srun -p rs2 python3 boguspython.py")

问题是如果第一个语句即

srun -p rs2 --mem-per-cpu 200G -t 7-23:00:00 python3 /home/usr/Sim/sim.py aok

需要等待资源分配,然后立即执行第二条语句。我的第二个命令依赖于第一个命令的完全执行。有没有办法让第二个语句等到第一个语句分配并完全完成?

I am running a script multiple times over a multinode cluster, and this script processes data sequentially over the cluster. Here is the code:

import os
os.system("srun -p rs2 --mem-per-cpu 200G -t 7-23:00:00 python3 /home/usr/Sim/sim.py aok; srun -p rs2 python3 boguspython.py")

The issue is that if the first statement i.e.

srun -p rs2 --mem-per-cpu 200G -t 7-23:00:00 python3 /home/usr/Sim/sim.py aok

needs to wait for an allocation of resources, then the second statement immediately executes. The second command I have relies on the first command being fully executed. Is there a way to make the second statement wait until the first statement allocates and fully finishes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╭⌒浅淡时光〆 2025-01-23 00:07:21

我建议使用 subprocess.Popen 而不是 os.system。这将允许您使用 .wait(),您可以在其中检查命令的完成状态。

I would suggest using subprocess.Popen instead of os.system. This will let you use .wait(), where you can check the status of a command for completion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文