[[TORQUE]]

本家様 [[http://www.adaptivecomputing.com/products/open-source/torque/>+http://www.adaptivecomputing.com/products/open-source/torque/]]

ジョブコントローラ。SGEと役目は同じなのだが、正直SGEは愚生には重すぎました。わからん...っで
slurmと共にTORQUEも検討した次第。slurmよりもネットに転がっている情報量が多いようで、
こちらTORQUEを使ってみる。


キュー作成[[TORQUE/queue]]
[[TORQUE/Preemption]]
[[TORQUE/BLCR]]
[[TORQUE/memo]]
[[TORQUE/job script]]
[[TORQUE/macOS]] [[TORQUE/windows10]] 

&size(10){以前掲載した[[torque-2.5.x>TORQUE151107]]は、EOSL(End Of Service Life)の模様};
&color(red){*}; &size(10){6.1.xより昔のバージョンは全てEOL/EOSLの様子(1709)、[[manualページ>+http://www.adaptivecomputing.com/support/documentation-index/torque-resource-manager-documentation/]]から};
&size(10){GPUs対応 [[TORQUE/GPUs]]};

マニュアル[[http://docs.adaptivecomputing.com/torque/4-2-10/help.htm>+http://docs.adaptivecomputing.com/torque/4-2-10/help.htm]]




その他のジョブコントローラ [[https://en.wikipedia.org/wiki/Comparison_of_cluster_software>+https://en.wikipedia.org/wiki/Comparison_of_cluster_software]]

***全体像 [#c173a3d2]

同一のネットワーク上に管理ノード、計算ノード、ジョブ発行ノードらが存在する。
そして、アカウント管理にはsamba ADを採用して、ユーザのホームディレクトリが各ノードと共有されているとする。
&size(10){各ノードのsamba ADへの参加は、[[samba/Linux参加]]を参考。ホームディレクトリの共有は[[NFS]]を参考に};
&ref(2015y11m07d_110530467.png,nolink,noborder);

管理ノードから計算ノードへのジョブ投入にはsshか、rshを利用する。
sshなら[[SSHホストベース認証>ssh/ホストベース認証]]か、authorized_keysを用意する。
rshを利用するなら &color(orangered){/etc/hosts.equiv}; の調整を行う。こちらの方が楽かな。

IPとか役目は下記参照
|BGCOLOR(yellow):役目|BGCOLOR(yellow):ホスト名|BGCOLOR(yellow):IPアドレス|BGCOLOR(yellow):core数|BGCOLOR(yellow):備考|
|管理ノード|pbs.sybyl.local|192.168.0.57|1||
|計算ノード|n1.sybyl.local|192.168.0.52|1|pbs_momが稼働&br;実際の計算を行う|
|~|n2.sybyl.local|192.168.0.53|2|~|
|~|n3.sybyl.local|192.168.0.54|3|~|
|ジョブ発行ノード|client.sybyl.local|192.168.0.20|1|qsub,qstat|
&color(red){*};&size(10){各マシンは最小構成で構築されて、[[samba/Linux参加/winbindd]]にてドメイン参加済み};


このようにフラットなネットワーク上に各ノードを繋げる方法の他にも、管理ノードに2つのネットワークを持たせて、
計算ノードを別のネットワーク下に置く方法もある。
&ref(2016y03m05d_231440168.png,nolink,noborder);
計算ノードだけのネットワークになるので、より効率的なのかも知れない。



***TORQUEパッケージの再構築 [#s15b7bfa]
gpuマシンがあるのでこれを有効にしてみた。
&color(red){*};&size(10){gpu対応のためにライブラリインストールは[[CUDA]]を参照};
&color(red){*};&size(10){c.sybyl.localにはnvidiaカードは入ってないがライブラリはカードの有無関係なくインストールできます};
&color(red){*};&size(10){既定であるmungeとcpusetはそのまま有効にした。numaも既定では有効だが、、怪しい挙動があったので無能にした。参照[[TORQUE/torque.spec]]};
#code(nonumber){{
[root@c ~]# yum install yum-utils
[root@c ~]# yumdownloader --enablerepo=epel --source torque
}}
にてtorqueのSPRMパッケージ torque-4.2.10-10.el7.src.rpm を取得した。このパッケージのSPECファイルを修正して再構築します。
#code(nonumber){{
[root@c ~]# rpm -Uvh torque-4.2.10-10.el7.src.rpm
[root@c ~]# vi rpmbuild/SPECS/torque.spec
}}
torque.specファイルの修正箇所[[TORQUE/torque.spec]]
その後、パッケージを作ります
#code(nonumber){{
[root@c ~]# rpmbuild -bb rpmbuild/SPECS/torque.spec
}}
完成したrpmパッケージは下記となる。これらのファイルを必要に応じて管理ノード、計算ノード、ジョブ発行ノードにコピーします。
#code(nonumber){{
[root@c ~]#
[root@c ~]# ls rpmbuild/RPMS/x86_64/
torque-4.2.10-10.el7.centos.x86_64.rpm              torque-gui-4.2.10-10.el7.centos.x86_64.rpm
torque-client-4.2.10-10.el7.centos.x86_64.rpm       torque-libs-4.2.10-10.el7.centos.x86_64.rpm
torque-debuginfo-4.2.10-10.el7.centos.x86_64.rpm    torque-mom-4.2.10-10.el7.centos.x86_64.rpm
torque-devel-4.2.10-10.el7.centos.x86_64.rpm        torque-pam-4.2.10-10.el7.centos.x86_64.rpm
torque-drmaa-4.2.10-10.el7.centos.x86_64.rpm        torque-scheduler-4.2.10-10.el7.centos.x86_64.rpm
torque-drmaa-devel-4.2.10-10.el7.centos.x86_64.rpm  torque-server-4.2.10-10.el7.centos.x86_64.rpm
[root@c ~]#
}}

各rpmパッケージに何が入っているかは rpm -qpl とかで見れます
#code(nonumber){{
[root@c ~]# rpm -qpl ./rpmbuild/RPMS/x86_64/torque-4.2.10-10.el7.centos.x86_64.rpm
/etc/torque/pbs_environment
/etc/torque/server_name
/usr/lib/systemd/system/trqauthd.service
/usr/sbin/trqauthd
 :
[root@c ~]#
}}


***管理ノードの構築 [#j55196bb]
&color(red){*};使用する torqueパッケージ(&size(10){これら管理ノードへコピーします};)
#code(nonumber){{
torque-4.2.10-10.el7.centos.x86_64.rpm
torque-libs-4.2.10-10.el7.centos.x86_64.rpm
torque-client-4.2.10-10.el7.centos.x86_64.rpm
torque-server-4.2.10-10.el7.centos.x86_64.rpm
}}
この作ったrpmファイルをインストールします。
#code(nonumber){{
[root@pbs ~]# yum -y localinstall \
      torque-4.2.10-10.el7.centos.x86_64.rpm \
      torque-libs-4.2.10-10.el7.centos.x86_64.rpm \
      torque-client-4.2.10-10.el7.centos.x86_64.rpm \
      torque-server-4.2.10-10.el7.centos.x86_64.rpm
}}

次に、管理ノードのサイトをserver_nameに定義して、pbs_serverのデータベースを作成する
#code(nonumber){{
[root@pbs ~]# hostname > /var/lib/torque/server_name
[root@pbs ~]# pbs_server -d /var/lib/torque -t create -f -D
pbs_server is up (version - 4.2.10, port - 15001)
}}
これでデータベースファイルは作成されますが、pbs_serverデーモンが稼動し続けています。
なのでここで &color(red){Ctrl-C}; によりpbs_serverデーモンを強制停止させます。
&color(red){*};&size(10){「pbs_server -t create」でデータベースファイルを作って終了すればいいのだが、、};

計算ノードのリストを用意します。npはノードあたりのcpuコア数です
#code(nonumber){{
[root@pbs ~]# vi /var/lib/torque/server_priv/nodes
n1.sybyl.local np=1
n2.sybyl.local np=2
n3.sybyl.local np=3
[root@pbs ~]#
}}
NUMAをサポートするなら、NUMAの数を定義に加える
#code(nonumber){{
[root@pbs ~]# vi /var/lib/torque/server_priv/nodes
n1.sybyl.local np=1 num_node_boards=1
n2.sybyl.local np=2 num_node_boards=1
n3.sybyl.local np=3 num_node_boards=1
[root@pbs ~]#
}}
&color(red){*};&size(10){計算ノードはFQDNにしないとエラー(&color(red){Node n1 is reporting on node n1.sybyl.local, which pbs_server doesn't know about};)が発生する場合がある};
&color(red){*};&size(10){「&color(red){num_node_boards};」はNUMAの数を示します。lscpuとかで確認できます。詳しくは[[ここを参照>+http://docs.adaptivecomputing.com/torque/4-1-4/Content/topics/1-installConfig/buildingWithNUMA.htm]]};
&color(red){*};&size(10){このNUMAを取り扱いたくないなら、configureで「&color(red){--enable-numa-support};」を外す};

mungeのキーを作成します
#code(nonumber){{
[root@pbs ~]# /usr/sbin/create-munge-key
Generating a pseudo-random key using /dev/urandom completed.
[root@pbs ~]#
}}
キーファイルは「/etc/munge/munge.key」に置かれます。
その後にtrqauthd、pbs_server、mungeを起動させます。
#code(nonumber){{
[root@pbs ~]# systemctl start trqauthd.service pbs_server.service munge.service
[root@pbs ~]# systemctl enable trqauthd.service pbs_server.service munge.service
}}
これでスケジューラを除いて管理ノードの基本はできた。
試しに現在の状況を確認すると
#code(nonumber){{
[root@pbs torque]# qmgr -c "p s"
#
# Set server attributes.
#
set server acl_hosts = pbs.sybyl.local
set server log_events = 511
set server mail_from = adm
set server scheduler_iteration = 600
set server node_check_rate = 150
set server tcp_timeout = 300
set server job_stat_rate = 45
set server poll_jobs = True
set server mom_job_sync = True
set server next_job_number = 0
set server moab_array_compatible = True
set server nppcu = 1
[root@pbs torque]#
}}
となる。管理ノードから直接ジョブ発行はできるのだが、あとでジョブ発行ノードを追加するので
そのサイトを登録する
#code(nonumber){{
[root@pbs ~]# qmgr -c 'set server submit_hosts = client'
}}

***管理ノードの構築その2、ジョブスケジューラ [#s0512ad7]

ジョブを割り振るスケジューラは、TORQUEで提供されている torque-scheduler でもいいのだが、細かい制御が無理。
なので、[[http://www.adaptivecomputing.com/products/open-source/maui/>+http://www.adaptivecomputing.com/products/open-source/maui/]]の maui を使用している。
開発環境とTorque-develをインストールして、このmauiをコンパイル/インストールします(&size(10){&color(green){/usr/local/maui};を起点にした};)

#code(nonumber){{
[root@pbs ~]# yum -y groupinstall "Development Tools" 
[root@pbs ~]# yum -y localinstall ./torque-devel-4.2.10-9.el7.centos.x86_64.rpm

[root@pbs ~]# gzip -cd maui-3.3.1.tar.gz | tar xf - && cd maui-3.3.1
[root@pbs maui-3.3.1]# ./configure --with-pbs=/usr
[root@pbs maui-3.3.1]# make && make install
[root@pbs maui-3.3.1]# cp etc/maui.d /etc/init.d
[root@pbs maui-3.3.1]# vi /etc/init.d/maui.d
- MAUI_PREFIX=/opt/maui
+ MAUI_PREFIX=/usr/local/maui
[root@pbs maui-3.3.1]#
}}
起動スクリプトは init.d しか提供されてなく、CentOS7の systemctl 向けのは用意されていない。
っで、作ってみた
#code(nonumber){{
[root@pbs ~]# vi /etc/systemd/system/maui.service
[Unit]
Description=maui job scheduler
After=syslog.target network.target

[Service]
Type=oneshot
ExecStart=/etc/init.d/maui.d  start
ExecStop=/etc/init.d/maui.d  start
ExecReload=/etc/init.d/maui.d restart
RemainAfterExit=yes
LimitNOFILE=32768

[Install]
WantedBy=multi-user.target

[root@pbs ~]#
[root@pbs ~]# systemctl --system daemon-reload
[root@pbs ~]# systemctl enable maui.service
[root@pbs ~]# systemctl start maui.service
}}
&color(red){*};&size(10){journalctlコマンドで起動を確認する};
&color(white,blue){留意};
mauiスケジューラは「gpu」に対応してません。なのでTorqueでgpuの占有を示すキーワードがあると止まります。
&size(10){たとえTorqueそのものをGPU対応で作ったとしても};
「#PBS -l nodes=1:ppn=1:gpus=1」とかの「gpus=1」があると駄目みたい。
mauiスケジューラの変わりにtorque-schedulerの「pbs_sched」スケジューラはgpuを扱えます。
[[TORQUE/scheduler]]

***計算ノード [#be26641c]
&color(red){*};使用する torqueパッケージ(&size(10){計算ノードへコピーします};)
#code(nonumber){{
torque-4.2.10-10.el7.centos.x86_64.rpm
torque-libs-4.2.10-10.el7.centos.x86_64.rpm
torque-mom-4.2.10-10.el7.centos.x86_64.rpm
}}
そしてインストール
#code(nonumber){{
[root@n1 ~]# yum -y localinstall ./torque-4.2.10-10.el7.centos.x86_64.rpm \
       torque-libs-4.2.10-10.el7.centos.x86_64.rpm torque-mom-4.2.10-10.el7.centos.x86_64.rpm
}}
&color(red){*};&size(10){同時にhwloc-lib、libtool-ltdl、munge、munge-libsがインストールされる};
次に、設定ファイル /var/lib/torque/mom_priv/config を修正して、
#code(nonumber){{
[root@n1 ~]# vi /var/lib/torque/mom_priv/config
$pbsserver pbs
$usecp *:/home /home
$log_file_suffix %h
$log_keep_days 10
[root@n1 ~]#
}}
&color(red){*};&size(10){「$log_file_suffix」が効かない。。 configure に「--with-momlogsuffix=%h」を入れると目的通りログにホスト名が付く};
起動させる
#code(nonumber){{
[root@n1 ~]# systemctl enable pbs_mom.service
[root@n1 ~]# systemctl start  pbs_mom.service
}}
管理ノードで確認をとる。
#code(nonumber){{
[root@pbs ~]# pbsnodes -l all
n1.sybyl.local       free
n2.sybyl.local       down
n3.sybyl.local       down
[root@pbs ~]#
}}
とn1が認識された。これを計算ノードの数だけ行う
&color(red){*};NUMAを有効にしていると下記のようになる
#code(nonumber){{
[root@pbs ~]# pbsnodes -l all
n1.sybyl.local-0     free
n2.sybyl.local       down
n3.sybyl.local       down
[root@pbs ~]#
}}

***ジョブ発行ノード [#h6416803]
&color(red){*};使用する torqueパッケージ(&size(10){ジョブ発行ノードへコピーします};)
#code(nonumber){{
torque-4.2.10-10.el7.centos.x86_64.rpm
torque-libs-4.2.10-10.el7.centos.x86_64.rpm
torque-client-4.2.10-10.el7.centos.x86_64.rpm
}}
そしてインストール。
#code(nonumber){{
[root@client ~]# yum -y localinstall ./torque-4.2.10-10.el7.centos.x86_64.rpm \
       torque-libs-4.2.10-10.el7.centos.x86_64.rpm torque-client-4.2.10-10.el7.centos.x86_64.rpm
}}
またmungeを使っているので管理ノードのmungeキーを貰い受けます
#code(nonumber){{
[root@pbs ~]# scp /etc/munge/munge.key root@client:/etc/munge

[root@client ~]# chown munge:munge /etc/munge/munge.key
}}

ジョブ発行ノードのサイトを定義して、trqauthd.serviceとmunge.serviceを起動させます
#code(nonumber){{
[root@client ~]# echo pbs > /var/lib/torque/server_name
[root@client ~]# systemctl enable trqauthd.service munge.service
[root@client ~]# systemctl start  trqauthd.service munge.service
}}

qmgr コマンドを使って通信テストを行います。
#code(nonumber){{
[root@client ~]# qmgr -c "p s"
#
# Set server attributes.
#
set server acl_hosts = pbs.sybyl.local
set server log_events = 511
set server mail_from = adm
set server scheduler_iteration = 600
set server node_check_rate = 150
set server tcp_timeout = 300
set server job_stat_rate = 45
set server poll_jobs = True
set server mom_job_sync = True
set server next_job_number = 0
set server moab_array_compatible = True
set server nppcu = 1
[root@client ~]#
}}
これでジョブ発行ノードの構築は完了

***キュー作成 [#ocf3deaf]

次の段階に進む前に、キューを作成します。
参照[[TORQUE/queue]]


***ジョブ発行 [#f4918b4b]
単純なスクリプトで確認してみる
#code(nonumber){{
[illya@client ~]$ echo "sleep 30" | qsub
3.pbs.sybyl.local
[illya@client ~]$ qstat -n

pbs.sybyl.local:
                                                                                  Req'd    Req'd       Elap
Job ID                  Username    Queue    Jobname          SessID  NDS   TSK   Memory   Time    S   Time
----------------------- ----------- -------- ---------------- ------ ----- ------ ------ --------- - ---------
3.pbs.sybyl.local       illya       batch    STDIN             12008     1      1    --  480:00:01 R       --
   n3
[illya@client ~]$
}}
#code(nonumber){{
[illya@client ~]$ cat a.sh
#!/bin/sh
#PBS -q bio
#PBS -l nodes=1:ppn=1
cd $PBS_O_WORKDIR
#--------------------------#
# write your job
sleep 30
echo `hostname`

[illya@client ~]$ qsub a.sh
4.pbs.sybyl.local

[illya@client ~]$ qstat -n

pbs.sybyl.local:
                                                                                  Req'd    Req'd       Elap
Job ID                  Username    Queue    Jobname          SessID  NDS   TSK   Memory   Time    S   Time
----------------------- ----------- -------- ---------------- ------ ----- ------ ------ --------- - ---------
4.pbs.sybyl.local       illya       bio      a.sh              11154     1      1    --        --  R  00:00:00
   n1
[illya@client ~]$
[illya@client ~]$ cat a.sh.o4
n1.sybyl.local

[illya@client ~]$
}}
qsubは指定されたリソースの予約確保を行い、その確保されたホストにジョブを1つ投入する。
nodes、ppnで指定された数だけジョブを投げるのではない。&color(magenta){''確保''};だけ行って、そこにジョブを投入するだけ。

だが、その後、投げられたジョブが起点となって確保したリソースを使用するかはジョブの中身次第。

mpirunであれば、最初にqsubから投げられたジョブがマスターノードになって、「-machinefile」で渡されたホストにジョブを投入する。

***計算ホストのcore数と nodes ファイルの記載 [#da9e5fcb]
server_priv/nodes に記載した「np」の値はそのマシンのコア数を表示するものであるが、別に異なっても構わない。

例として、n3.sybyl.localは、1cpu/1coreで動いているが、
#code(nonumber){{
[root@n3 ~]# LANG=C lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE
0   0    0      0    0:0:0:0       yes
[root@n3 ~]#
}}
server_priv/nodesで「np=3」としていると
#code(nonumber){{
[root@pbs ~]# pbsnodes n3.sybyl.local
n3.sybyl.local
     state = free
     np = 3
(略
[root@pbs ~]#
}}
と認識される

これはconfigureの際、「cpuset」を有効にすれば回避され、ハードウエアにあわせて「np」の値が変更されます。
&size(10){関連擁護としては cgroup とか hwloc かな};

ここではわざと「cpuset」を無効にしてます。

***ジョブスクリプトで使用可能なTORQUE由来の環境変数 [#s42d46a1]
下記のスクリプトを流して環境変数を得た見た
#code(nonumber){{
[illya@pbs ~]$ vi a.sh
#!/bin/sh
#PBS -q bio
#PBS -l nodes=3:ppn=2
#PBS -j oe
env
[illya@pbs ~]$ qsub a.sh
}}
「env」コマンドで得られた結果から先頭文字PBSの値を書きに掲載

|BGCOLOR(YELLOW):変数名|BGCOLOR(YELLOW):値|BGCOLOR(YELLOW):備考|
|PBS_VERSION|TORQUE-4.2.10||
|PBS_JOBNAME|a.sh|実行したスクリプトファイル名|
|PBS_ENVIRONMENT|PBS_BATCH||
|PBS_O_WORKDIR|/home/illya|スクリプトを実行した場所|
|PBS_TASKNUM|1||
|PBS_O_HOME|/home/illya|実行者のホームディレクトリ|
|PBS_WALLTIME|864000||
|PBS_MOMPORT|15003||
|PBS_GPUFILE|/var/lib/torque/aux//8.pbs.sybyl.localgpu||
|PBS_O_QUEUE|bio|使用したキューの名称|
|PBS_O_LOGNAME|illya|実行者(ログイン名)|
|PBS_O_LANG|en_US.UTF-8||
|PBS_JOBCOOKIE|B3825133EF21DE765747CC0B926951E0||
|PBS_NODENUM|0||
|PBS_NUM_NODES|3|nodesの値|
|PBS_O_SHELL|/bin/bash|使用したシェル|
|PBS_JOBID|8.pbs.sybyl.local||
|PBS_O_HOST|pbs.sybyl.local|ジョブを発行したホスト|
|PBS_VNODENUM|0||
|PBS_QUEUE|bio|使用したキューの名称(PBS_O_QUEUEと同じ?)|
|PBS_O_MAIL|/var/spool/mail/illya||
|PBS_MICFILE|/var/lib/torque/aux//8.pbs.sybyl.localmic||
|PBS_NP|6|確保したCPUリソース|
|PBS_O_SERVER|pbs.sybyl.local||
|PBS_NUM_PPN|2|ppnの値|
|PBS_NODEFILE|/var/lib/torque/aux//8.pbs.sybyl.local||
|PBS_O_PATH|(PATH)||

***ジョブスクリプトでの環境変数を組み込んで、それがmpirunで各計算ノードに波及するのか? [#la0ec493]
簡単なスクリプトで検証する
まずジョブスクリプト
#code(nonumber){{
[illya@pbs ~]$ vi a.sh
#!/bin/sh
#PBS -q bio
#PBS -l nodes=2:ppn=1
#PBS -j oe
#
cd $PBS_O_WORKDIR
#
export PATH=/Appl/Linux/NAMD_2.11_Linux-x86_64-multicore:$PATH    <---この環境変数がmpirunで各計算ノードに渡るのか検証
#
mpirun -np 2 /home/illya/b.sh

[illya@pbs ~]$
}}
mpirunで実行される b.sh は
#code(nonumber){{
[illya@pbs ~]$ vi b.sh
#!/bin/bash
echo $PATH

[illya@pbs ~]$
}}
と単純にPATH環境変数のみを返す。
そして、これを実際にqsub経由で流してみる
#code(nonumber){{
[illya@pbs ~]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/illya/.local/bin:/home/illya/bin

[illya@pbs ~]$ qsub a.sh
}}
すぐさま完了して、そのログを見てみると
#code(nonumber){{
[illya@pbs ~]$ cat a.sh.o9
/Appl/Linux/NAMD_2.11_Linux-x86_64-multicore:/usr/local/bin:/usr/bin:/usr/local/sbin:(略
/Appl/Linux/NAMD_2.11_Linux-x86_64-multicore:/usr/local/bin:/usr/bin:/usr/local/sbin:(略
[illya@pbs ~]$
}}
と指定したPATHが含まれて各計算ノードに渡っていた

***特定のノードで計算したい [#b781d9a3]
利用可能なリソースから空いている計算機にジョブを投げるのが「うり」なのだが、ノードを指定して計算することもできる
nodesを使用するノードの数ではなく、ホスト名を入れれば計算ノードが指定される。
#code(nonumber){{
[illya@pbs ~]$ vi a.sh
#!/bin/sh
#PBS -q bio
#PBS -l nodes=n1.sybyl.local:ppn=1
#PBS -j oe
#
(略

[illya@pbs ~]$
}}
複数指定をするなら
#code(nonumber){{
[illya@pbs ~]$ vi a.sh
#!/bin/sh
#PBS -q chem
#PBS -l nodes=n2.sybyl.local:ppn=2+n3.sybyl.local:ppn=2
#PBS -j oe
#
(略

[illya@pbs ~]$
}}
として「+」で繋げる

1

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS