我正在尝试调整一些 bash 脚本以使它们在 ( pbs ) 集群上运行。
各个任务由几个脚本执行,这些脚本由一个主脚本启动。到目前为止,这个主脚本在后台启动了多个脚本(通过附加&
),使它们在一台多核机器上并行运行。我想用qsub
s 替换这些调用以在集群节点之间分配负载。
但是,有些工作需要其他工作完成才能开始。到目前为止,这是通过wait
主脚本中的语句实现的。但是,使用 Grid Engine 执行此操作的最佳方法是什么?
我已经在手册页中找到了这个问题以及-W after:jobid[:jobid...]
文档,qsub
但我希望有更好的方法。我们正在谈论首先并行运行的几个 thound 作业,然后在最后一个完成后同时运行另一组相同大小的作业。这意味着我必须根据很多工作排队很多工作。
我可以通过在两者之间使用一个虚拟工作来解决这个问题,除了依赖第一组工作之外什么都不做,第二组可以依赖这些工作。这会将依赖项的数量从数百万减少到数千,但仍然:感觉不对,我什至不确定 shell 是否会接受这么长的命令行。
- 有没有办法等待我所有的工作完成(比如
qwait -u <user>
)? - 或者从这个脚本提交的所有作业(类似
qwait [-p <PID>]
)?
当然,使用qstat
andsleep
在while
循环中编写这样的东西是可能的,但我想这个用例很重要,足以拥有一个内置的解决方案,而我只是无法弄清楚这一点。
在这种情况下,您会推荐/使用什么?
附录一:
由于它是在评论中要求的:
$ qsub --version
version: 2.4.8
也许也有助于确定确切的pbs系统:
$ qsub --help
usage: qsub [-a date_time] [-A account_string] [-b secs]
[-c [ none | { enabled | periodic | shutdown |
depth=<int> | dir=<path> | interval=<minutes>}... ]
[-C directive_prefix] [-d path] [-D path]
[-e path] [-h] [-I] [-j oe] [-k {oe}] [-l resource_list] [-m n|{abe}]
[-M user_list] [-N jobname] [-o path] [-p priority] [-P proxy_user] [-q queue]
[-r y|n] [-S path] [-t number_to_submit] [-T type] [-u user_list] [-w] path
[-W otherattributes=value...] [-v variable_list] [-V] [-x] [-X] [-z] [script]
由于到目前为止的注释指向作业数组,因此我在qsub
手册页中搜索了以下结果:
[...]
DESCRIPTION
[...]
In addition to the above, the following environment variables will be available to the batch job.
[...]
PBS_ARRAYID
each member of a job array is assigned a unique identifier (see -t)
[...]
OPTIONS
[...]
-t array_request
Specifies the task ids of a job array. Single task arrays are allowed.
The array_request argument is an integer id or a range of integers. Multiple ids or id ranges can be combined in a comman delimeted list. Examples : -t 1-100 or -t 1,10,50-100
[...]
附录二:
我已经尝试过 Dmitri Chubarov 给出的扭矩解决方案,但它不像描述的那样工作。
如果没有作业阵列,它会按预期工作:
testuser@headnode ~ $ qsub -W depend=afterok:`qsub ./test1.sh` ./test2 && qstat
2553.testserver.domain
Job id Name User Time Use S Queue
----------------------- ---------------- --------------- -------- - -----
2552.testserver Test1 testuser 0 Q testqueue
2553.testserver Test2 testuser 0 H testqueue
testuser@headnode ~ $ qstat
Job id Name User Time Use S Queue
----------------------- ---------------- --------------- -------- - -----
2552.testserver Test1 testuser 0 R testqueue
2553.testserver Test2 testuser 0 H testqueue
testuser@headnode ~ $ qstat
Job id Name User Time Use S Queue
----------------------- ---------------- --------------- -------- - -----
2553.testserver Test2 testuser 0 R testqueue
但是,使用作业数组第二个作业不会开始:
testuser@headnode ~ $ qsub -W depend=afterok:`qsub -t 1-2 ./test1.sh` ./test2 && qstat
2555.testserver.domain
Job id Name User Time Use S Queue
----------------------- ---------------- --------------- -------- - -----
2554-1.testserver Test1-1 testuser 0 Q testqueue
2554-2.testserver Test1-1 testuser 0 Q testqueue
2555.testserver Test2 testuser 0 H testqueue
testuser@headnode ~ $ qstat
Job id Name User Time Use S Queue
----------------------- ---------------- --------------- -------- - -----
2554-1.testserver Test1-1 testuser 0 R testqueue
2554-2.testserver Test1-2 testuser 0 R testqueue
2555.testserver Test2 testuser 0 H testqueue
testuser@headnode ~ $ qstat
Job id Name User Time Use S Queue
----------------------- ---------------- --------------- -------- - -----
2555.testserver Test2 testuser 0 H testqueue
我猜这是由于第一个返回的作业 id 中缺少数组指示qsub
:
testuser@headnode ~ $ qsub -t 1-2 ./test1.sh
2556.testserver.domain
如您所见,没有...[]
表明这是一个作业数组。此外,在qsub
输出中没有...[]
s 但...-1
表示...-2
数组。
所以剩下的问题是如何格式化-W depend=afterok:...
以使作业依赖于指定的作业数组。