加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell – 在将后续作业提交到PBS群集之前等待用户的所有作业完成

发布时间:2020-12-15 21:47:27 所属栏目:安全 来源:网络整理
导读:我正在尝试调整一些bash脚本,使它们在( pbs)集群上运行. 各个任务由几个由主脚本启动的脚本执行. 到目前为止,这个主要脚本在后台启动多个脚本(通过附加)使它们在一个多核机器上并行运行. 我想用qsubs替换这些调用来分配集群节点的负载. 但是,有些工作依赖于
我正在尝试调整一些bash脚本,使它们在( pbs)集群上运行.

各个任务由几个由主脚本启动的脚本执行.
到目前为止,这个主要脚本在后台启动多个脚本(通过附加&)使它们在一个多核机器上并行运行.
我想用qsubs替换这些调用来分配集群节点的负载.

但是,有些工作依赖于其他工作才能开始.
到目前为止,这是通过主脚本中的等待语句实现的.
但是使用Grid Engine的最佳方法是什么?

我已经在qsub手册页中找到了this question以及-W after:jobid [:jobid …]文档,但我希望有更好的方法.
我们正在谈论几个并行运行的thousend作业和另一个相同大小的一组,以便在最后一个完成之后同时运行.
这意味着我必须根据很多工作排队很多工作.

我可以通过在中间使用虚拟作业来减少这种情况,除了取决于第二组可能依赖的第一组作业之外什么都不做.
这会将依赖数量从数百万减少到数千,但仍然是:它是错误的,我甚至不确定shell是否会接受如此长的命令行.

>是不是有办法等待我的所有工作完成(像qwait -u< user>)?
>或者从这个脚本提交的所有作业(如qwait [-p< PID>])?

当然可以使用qstat编写类似的东西并在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给出的torque解决方案,但它没有按照描述工作.

没有工作,它按预期工作:

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

我想这是由于第一个qsub返回的作业ID中缺少数组指示:

testuser@headnode ~ $qsub -t 1-2 ./test1.sh
2556.testserver.domain

正如你所看到的,没有… []表明这是一个工作阵列.
此外,在qsub输出中没有… [] s但是……- 1和…- 2表示阵列.

所以剩下的问题是如何格式化-W depend = afterok:…使作业依赖于指定的作业数组.

解决方法

填写Jonathan在评论中提出的解决方案.

基于最初的Portable Batch System有几个资源管理器:OpenPBS,TORQUE和PBS Professional.这些系统显着不同,并且对诸如作业数组之类的新功能使用不同的命令语法.

作业数组是基于相同作业脚本提交多个类似作业的便捷方式.引自手册:

Sometimes users will want to submit large numbers of jobs based on the
same job script. Rather than using a script to repeatedly call qsub,a
feature known as job arrays now exists to allow the creation of
multiple jobs with one qsub command.

要提交作业数组,PBS提供以下语法:

qsub -t 0-10,13,15 script.sh

这提交了来自0,1,2,…,15的ID的作业.

在脚本中,变量PBS_ARRAYID携带数组中作业的id,并可用于选择必要的配置.

作业数组具有其特定的依赖选项.

TORQUE

可能在OP中使用的TORQUE资源管理器.提供了其他依赖选项,可在以下示例中看到:

$qsub -t 1-1000 script.sh
1234[].pbsserver.domainname
$qsub -t 1001-2000 -W depend=afterokarray:1234[] script.sh
1235[].pbsserver.domainname

这将导致以下qstat输出

1234[]         script.sh    user          0 R queue
1235[]         script.sh    user          0 H queue

扭矩版3.0.4测试

完整的afterokarray语法在qsub(1)手册中.

PBS专业版

在PBS Professional中,依赖关系可以在普通作业和数组作业上统一工作.这是一个例子:

$qsub -J 1-1000 -ry script.sh
1234[].pbsserver.domainname
$qsub -J 1001-2000 -ry -W depend=afterok:1234[] script.sh
1235[].pbsserver.domainname

这将导致以下qstat输出

1234[]         script.sh    user          0 B queue
1235[]         script.sh    user          0 H queue

扭矩版本更新

从版本2.5.3开始,Torque中提供了数组依赖性.版本2.5中的作业数组与版本2.3或2.4中的作业数组不兼容.特别是[]语法是从版本2.5开始在Torque中引入的.

更新使用分隔工作

对于2.5之前的扭矩版本,可以使用不同的解决方案,该解决方案基于在要分离的批次作业之间提交虚拟分隔工作.
它使用三种依赖类型:on,before和after.

请考虑以下示例

$DELIM=`qsub -Wdepend=on:1000 dummy.sh `
 $qsub -Wdepend=beforeany:$DELIM script.sh
 1001.pbsserver.domainname
 ... another 998 jobs ...
 $qsub -Wdepend=beforeany:$DELIM script.sh
 2000.pbsserver.domainname
 $qsub -Wdepend=after:$DELIM script.sh
 2001.pbsserver.domainname
 ...

这将导致这样的队列状态

1000         dummy.sh    user          0 H queue
1001         script.sh   user          0 R queue   
...
2000         script.sh   user          0 R queue   
2001         script.sh   user          0 H queue
...

这就是#2001工作仅在前1000个作业终止后才会运行.可能也可以使用TORQUE 2.4中提供的基本作业数组工具来提交脚本作业.

此解决方案也适用于TORQUE 2.5及更高版本.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读