如果第一个命令未分配,则通过 slurm 调度程序暂停 os.system 命令
我在多节点集群上多次运行脚本,并且该脚本在集群上按顺序处理数据。这是代码:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用
subprocess.Popen
而不是os.system
。这将允许您使用.wait()
,您可以在其中检查命令的完成状态。I would suggest using
subprocess.Popen
instead ofos.system
. This will let you use.wait()
, where you can check the status of a command for completion.