Clusters形式
「Master」と「Worker」を別々の計算機に組み込みます
そしてジョブを実行する際、「Master-Worker」方式ではブラウザから利用する計算ノードを手動で選びますが、
この Cluster 形式ではその選択に ジョブ管理システム を使用します
目下使用できる ジョブ管理システム は
となっているみたい. ここでは OpenPBS を採用しています.
masterとworkerの構築は cryoSPARC/Master-Workerを参照してください.
そしてジョブ管理システムの設定でmasterノードはジョブ発行ノードとしての機能を持たせて、
各workerノードには計算ノードの機能を持たせます。
次にジョブ管理システム毎の設定シート(cluster_info.jsonとcluster_script.sh)を作成します
テンプレート作成 †
まずはそのテンプレートを取得.
[saber@cryosparc ~]$ cryosparcm cluster example
Writing example cluster_info.json and cluster_script.sh to current dir
Unknown cluster type. Supported templates are:
pbs
slurm
gridengine
Any cluster scheduler is supported, but you may have to write your own custom submission script.
[saber@cryosparc ~]$
ここではOpenPBSを使用するので「pbs」のテンプレートを頂きます。
[saber@cryosparc ~]$ cryosparcm cluster example pbs
Writing example cluster_info.json and cluster_script.sh to current dir
[saber@cryosparc ~]$
すると、コマンドを実行した場所に設定ファイルのテンプレート「cluster_info.json」と「cluster_script.sh」が置かれます.
テンプレートcluster_info.jsonの中身は
*ここのpukiwikiの記述ルールの問題から「}}」を「} }」にしています
[saber@cryosparc ~]$ cat cluster_info.json
{
"name" : "pbscluster",
"worker_bin_path" : "/path/to/cryosparc_worker/bin/cryosparcw",
"cache_path" : "/path/to/local/SSD/on/cluster/nodes"
"send_cmd_tpl" : "ssh loginnode {{ command } }",
"qsub_cmd_tpl" : "qsub {{ script_path_abs } }",
"qstat_cmd_tpl" : "qstat -as {{ cluster_job_id } }",
"qdel_cmd_tpl" : "qdel {{ cluster_job_id } }",
"qinfo_cmd_tpl" : "qstat -q",
"transfer_cmd_tpl" : "scp {{ src_path } } loginnode:{{ dest_path } }"
}
[saber@cryosparc ~]$
こんな感じ。もう一つのcluster_script.shは
*ここのpukiwikiの記述ルールの問題から「}}」を「} }」にしています
[cryosparc@c ~]$ cat cluster_script.sh
[saber@cryosparc ~]$ cat cluster_script.sh
#!/usr/bin/env bash
#### cryoSPARC cluster submission script template for PBS
## Available variables:
## {{ run_cmd } } - the complete command string to run the job
## {{ num_cpu } } - the number of CPUs needed
## {{ num_gpu } } - the number of GPUs needed.
## Note: the code will use this many GPUs starting from dev id 0
## the cluster scheduler or this script have the responsibility
## of setting CUDA_VISIBLE_DEVICES so that the job code ends up
## using the correct cluster-allocated GPUs.
## {{ ram_gb } } - the amount of RAM needed in GB
## {{ job_dir_abs } } - absolute path to the job directory
## {{ project_dir_abs } } - absolute path to the project dir
## {{ job_log_path_abs } } - absolute path to the log file for the job
## {{ worker_bin_path } } - absolute path to the cryosparc worker command
## {{ run_args } } - arguments to be passed to cryosparcw run
## {{ project_uid } } - uid of the project
## {{ job_uid } } - uid of the job
## {{ job_creator } } - name of the user that created the job (may contain spaces)
## {{ cryosparc_username } } - cryosparc username of the user that created the job (usually an email)
##
## What follows is a simple PBS script:
#PBS -N cryosparc_{{ project_uid } }_{{ job_uid } }
#PBS -l select=1:ncpus={{ num_cpu } }:ngpus={{ num_gpu } }:mem={{ (ram_gb*1000)|int } }mb:gputype=P100
#PBS -o {{ job_dir_abs } }
#PBS -e {{ job_dir_abs } }
available_devs=""
for devidx in $(seq 1 16);
do
if [[ -z $(nvidia-smi -i $devidx --query-compute-apps=pid --format=csv,noheader) ]] ; then
if [[ -z "$available_devs" ]] ; then
available_devs=$devidx
else
available_devs=$available_devs,$devidx
fi
fi
done
export CUDA_VISIBLE_DEVICES=$available_devs
{{ run_cmd } }
[saber@cryosparc ~]$
こんな感じ。これら2つを既設のジョブ管理システムに会うように調整します
cluster_info.json †
変更箇所
- name:
cryoSPARCで認識できる名称
- worker_bin_path
workerノードでの「cryosparcw」までの絶対パス
- cache_path
worker全計算ノードでのssdパス. 「/scratch/cryoSPARC」とか 指定なしはブランクとする
- send_cmd_tpl
masterノードが直接qsubを実行できないシーンで、qsubを実行できるノードに接続するコマンド
*ここのpukiwikiの記述ルールの問題から「}}」を「} }」にしています
| --- cluster_info.json.orig 2021-04-25 01:21:00.555984725 +0900
+++ cluster_info.json 2021-04-25 05:22:37.673773344 +0900
@@ -1,11 +1,11 @@
{
"name" : "pbscluster",
- "worker_bin_path" : "/path/to/cryosparc_worker/bin/cryosparcw",
- "cache_path" : "/path/to/local/SSD/on/cluster/nodes"
- "send_cmd_tpl" : "ssh loginnode {{ command } }",
+ "worker_bin_path" : "/home/saber/cryoSPARC/cryosparc_worker/bin/cryosparcw",
+ "cache_path" : "",
+ "send_cmd_tpl" : "{{ command } }",
"qsub_cmd_tpl" : "qsub {{ script_path_abs } }",
"qstat_cmd_tpl" : "qstat -as {{ cluster_job_id } }",
"qdel_cmd_tpl" : "qdel {{ cluster_job_id } }",
"qinfo_cmd_tpl" : "qstat -q",
- "transfer_cmd_tpl" : "scp {{ src_path } } loginnode:{{ dest_path } }"
+ "transfer_cmd_tpl" : "cp {{ src_path } } {{ dest_path } }"
}
|
cluster_script.sh †
既定では ngpus や mem もリソース要因として載せてますが、ここではそれらを削ってます.
*ここのpukiwikiの記述ルールの問題から「}}」を「} }」にしています
| --- cluster_script.sh.orig 2021-04-25 01:21:00.565984935 +0900
+++ cluster_script.sh 2021-04-25 03:03:48.525679266 +0900
@@ -22,12 +22,12 @@
## What follows is a simple PBS script:
#PBS -N cryosparc_{{ project_uid } }_{{ job_uid } }
-#PBS -l select=1:ncpus={{ num_cpu } }:ngpus={{ num_gpu } }:mem={{ (ram_gb*1000)|int } }mb:gputype=P100
+#PBS -l select=1:ncpus={{ num_cpu } }
#PBS -o {{ job_dir_abs } }
#PBS -e {{ job_dir_abs } }
available_devs=""
-for devidx in $(seq 1 16);
+for devidx in $(seq 0 16);
do
if [[ -z $(nvidia-smi -i $devidx --query-compute-apps=pid --format=csv,noheader) ]] ; then
if [[ -z "$available_devs" ]] ; then
|
*「for devidx in $(seq 1 16);」は間違いだと思っている. 「1」ならGPU-ID:0を飛ばしてそれ以外を探すことになる. 4GPUで計算したいのに3つしか使えない事が起こりえる. slurm版だとここが「0」なんだよなぁ. 親切に「0」をモニター用として使わない? qsubで動かす前提ならそのような枷は不要だと思うのだが..
カスタマイズしたテンプレートの取り込み †
こうしてカスタマイズしたcluster_info.jsonとcluster_script.shをシステムに反映させるには、
これらのファイルが置かれた場所で「cryosparcm cluster connect」を実行します
[saber@cryosparc ~]$ cryosparcm cluster connect
:
Successfully added cluster lane pbscluster
(確認は下記コマンドで)
[saber@cryosparc ~]$ cryosparcm cli "get_scheduler_lanes()"
(削除はcluster_info.jsonのnameを使います)
[saber@cryosparc ~]$ cryosparcm cluster remove pbscluster
これで反映できました。
複数のqueueを作りたい †
例えば、特定の計算機にcryoSPARCジョブを流したいとかがある。
リソースの最適な分配は ジョブ管理システム で行うが、そうであっても特定の計算機にジョブを流したいことはある
加えて、ジョブ管理システム を経ないでジョブを勝手に流すと他のユーザのジョブに影響が及ぶ. なのであくまでもジョブ管理システムの下で指定する必要がある
例えば、OpenPBSで特定の計算機を指定するには
qsub -q workq -l select=1:ncpus=8:host=s -I
「1ノードでcore数が8のhost名がsなノードをインターラクティヴモードで接続」
と指定します。 「-l」の後にhostが来るとダメみたい. selectが来ないと
これを模します.
「cluster_info.json」は
| --- cluster_info.json.pbscluster 2021-04-25 04:07:49.614387651 +0900
+++ cluster_info.json 2021-04-25 04:07:19.611757357 +0900
@@ -1,5 +1,5 @@
{
- "name" : "pbscluster",
+ "name" : "run-on-s",
"worker_bin_path" : "/home/saber/cryoSPARC/cryosparc_worker/bin/cryosparcw",
"cache_path" : "",
"send_cmd_tpl" : "{{ command } }",
|
として、「cluster_script.sh」は下記のようにします.
| --- cluster_script.sh.pbscluster 2021-04-25 03:40:45.286240573 +0900
+++ cluster_script.sh 2021-04-25 03:41:40.361398185 +0900
@@ -22,7 +22,7 @@
## What follows is a simple PBS script:
#PBS -N cryosparc_{{ project_uid } }_{{ job_uid } }
-#PBS -l select=1:ncpus={{ num_cpu } }
+#PBS -l select=1:ncpus={{ num_cpu } }:host=s
#PBS -o {{ job_dir_abs } }
#PBS -e {{ job_dir_abs } }
|
これを取り込み当たなlane 「run-on-s」が用意されます.
[saber@cryosparc ~]$ cryosparcm cluster connect
:
Successfully added cluster lane run-on-s
[saber@cryosparc ~]$
今登録されているclusterは? †
cryosparcm cli "get_scheduler_lanes()"
にて表示される
っで削除は
cryosparcm cli "remove_scheduler_lane('em-g1-a01')"
とlaneの名前を入れます
メモ †
cryoSPARCではどのGPUを使うかはスクリプトで決めている.
「nvidia-smi -i $i --query-compute-apps=pid --format=csv,noheader」
この「$i」を0から16まで動かしてエラーではなく値の無いもので計算をさせる.
っが、やっすいGPUカードだとこの「nvidia-smi -i 0 --query-compute-apps=pid --format=csv,noheader」が正しく動かない.
それで対応GPUがないとかでジョブが停止します.
あと使われていないGPUを探すのはいいのだが、2つGPUを使って計算していて、他のジョブ(relion)が来たとして
その使っているGPU-IDを避けてGPU-IDが指定されるか微妙...
そこらは cgroupやHookを使う必要があり、結構面倒. 可能な限り1台で済ませるようなジョブ投入が宜しいかと.
「[Errno 2] No such file or directory: 'qsub': 'qsub'」と表示されたらそれはmasterでqsubへのPATHが入っていない可能性
openPBSでhookを利用した場合 †
てすと中
cluster_script.shが要求するのは nvidia-smi で出力されるID(0,1,2,...)である.
しかしopenPBSでhookを有効にするとCUDA_VISIBLE_DEVICESには UUID っぽい値が適用される.
それを0,1,2に変換する様にしてみた
list=(${CUDA_VISIBLE_DEVICES//,/ })
n=0
available_devs=""
for i in ${list[@]} ; do
if [ $n -eq 0 ]; then
available_devs=$n
else
available_devs=$available_devs,$n
fi
n=$(( $n + 1 ))
done
export CUDA_VISIBLE_DEVICES=$available_devs