LoginSignup
9
3

More than 3 years have passed since last update.

産総研スパコンABCIの使い方メモ

Last updated at Posted at 2020-04-01

はじめに

産総研のGPU付きスパコン”ABCI”を昨年度末まで使っていたのでそのときのメモ.とくにABCIの計算ノードでAnacondaの仮想環境を動かしたい方はご参考にどうぞ.

※注意:この内容は2020年3月までの知識で書いています

参考資料など

インタラクティブノードへのログイン

WindowsならWindows Powershell,Powershellを使う,あるいはWindows TerminalからWSLを使うが良いと思います.私はWindows Terminal + WSLを使っていました.

shell-window-1
$ ssh -i ./your_rsa_key -L 10022:es:22 -l $YOUR_ABCI_ID as.abci.ai

正しいパスワードを入れると以下のようなメッセージが出ます

shell-window-1
Welcome to ABCI access server.
Please press any key if you disconnect this session.

このshell-window-1はこのままキープしておきます.キープしたまま別windowを開き以下を入力します.

shell-window-2
$ ssh -i ./your_rsa_key -p 10022 -l $YOUR_ABCI_ID localhost

正しいパスワード入力後,以下のメッセージが出ればログイン成功です.

shell-window-2
--------------------------------------------------------------------------------
  ABCI Information                                           Date: Oct 04, 2019
--------------------------------------------------------------------------------

  Welcome to ABCI system

  - How to use
    Please see below for ABCI Users Guide:

    - https://docs.abci.ai/en/ (In English)
    - https://docs.abci.ai/ja/ (In Japanese)

  If you have any questions or need for further assistance,
  please refer to the following URL and contact us:

    - https://abci.ai/en/how_to_use/user_support.html (In English)
    - https://abci.ai/ja/how_to_use/user_support.html (In Japanese)

[xxxxxxxxxx@es1 ~]$ 

ログアウトで消えない環境変数を作る場合は~/.bash_profileに書き込みます.ユーザID,グループID,メールアドレス,グループディレクトリあたりを環境変数にしておくと何かと便利です.

shell-window-2
[xxxxxxxxxx@es1 ~]$ cat .bash_profile
# .bash_profile

## Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

## User specific environment and startup programs
export PATH=$PATH:$HOME/.local/bin:$HOME/bin

## Original
export ID_USER=xxxxxxxxxx
export ID_GROUP=xxxxxxxx
export EMAIL=xxxxxx@xxxx.xxx.xxx.xx.jp
export DIR_GROUP=/groups1/$ID_GROUP

Anacondaのインストール後,以下コマンドを入力しcondaコマンドを有効化します.

shell-window-2
[xxxxxxxxxx@es1 ~]$ export PATH=~/anaconda3/bin:$PATH

インタラクティブノードでJupyter labを使用

サーバー側のブラウザで開かずにJupyter labを起動しサーバのアドレスを確認します.

shell-window-2
[xxxxxxxxxx@es1 ~]$ jupyter lab --no-browser --ip=`hostname` >> jupyter.log 2>&1 &
[xxxxxxxxxx@es1 ~]$ jupyter notebook list
Currently running servers:
http://es1.abci.local:8888/?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX :: /home/xxxxxxxxxx

新しいシェルウィンドウを開いてポートフォワーディングします.以下を入力し,パスワードを入力します.「es1」「8888」とは限らないので,毎回上記のrunning serverのアドレスで確認してください.

shell-window-3
$ ssh -L 18888:es1:8888 -l $YOUR_ABCI_ID -i ./your_rsa_key -p 10022 localhost

shell-window-3をこの状態でキープしたまま,ログイン元のPCのブラウザを立ち上げ,

http://localhost:18888/?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

にアクセスします."token="以下はshell-window-2に表示されているものをコピーしてください.

On-demandモードで計算ノードを使用

qrshコマンドを使った計算ノードへのログイン

shell-window-2
[xxxxxxxxxx@es1 ~]$ qrsh -l rt_G.small=1 -g $ID_GROUP -l h_rt=00:30:00

@の後ろがgからはじまるノード名になっていれば成功です.インタラクティブノードの何処にいてもhomeディレクトリに移動するので注意してください

shell-window-2
[xxxxxxxxxx@g0001 ~]$ 

計算ノードでJupyter labを使用

基本的にインタラクティブノードでJupyter labを使用するのと手順は同じです.ポートフォワーディングする際,ノード名のes~をg~にすげ替えてください.

Spotモードで計算ノードを使用

事前に計算ノードにログインしておく必要はありません.

shell-window-2
[xxxxxxxxxx@es1 ~]$ qsub -j y -cwd -l rt_G.small=1 -l h_rt=24:00:00 -g $ID_GROUP -M $EMAIL -m besa -o $DIR_LOG -e $DIR_LOG ./run.sh

DIR_LOGは事前に適当なディレクトリを指定しておいてください.カレントディレクトリでよいのなら

shell-window-2
[xxxxxxxxxx@es1 ~]$ export DIR_LOG=$(pwd)

でOKです.

Anacondaで作成した仮想環境を使用したい場合は上記run.shの中身をたとえば以下のようにします:

run.sh
#!/bin/bash

## >>> conda init >>>

__conda_setup="$(CONDA_REPORT_ERRORS=false '$HOME/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"

if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "$HOME/anaconda3/etc/profile.d/conda.sh" ]; then
        . "$HOME/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="$PATH:$HOME/anaconda3/bin"
    fi
fi
unset __conda_setup
## <<< conda init <<< 

## Activation
conda activate myenv1

## このへんは確認のために表示
conda info -e
date
hostname

## Pythonコードを実行
python main.py arg1 arg2 arg3

Reservedモードで計算ノードを使用

[2020/05/22追記]

予約と予約の削除

公式のマニュアルを参考にしてください(わかりやすいので)
https://docs.abci.ai/ja/03/#reservation

予約にはqrsubコマンドを使います.
-a : ジョブの開始日をYYYYMMDD形式で指定します.ジョブは開始日の朝10時に開始されます.朝10時以降に当日を指定すると何かしらのエラーが出ます
-d : ジョブの実行期間(日数)を指定します.-aで指定した開始日のN日後の朝9時30分に実行が停止されます.下の-eかこの-dのどちらか片方を指定します.
-e : ジョブの停止日時を指定します.YYYYMMDDで指定した日の朝9時30分に実行が停止されます.上の-dかこの-eどちらか片方を指定します.
-N : 予約名を文字列で指定します.頭に数字を指定することは出来ません.

shell-window-2
[xxxxxxxxxx@es1 ~]$ qrsub -a 20180705 -d 7 -g grpname -n 4 -N "Reserve_for_AI"
Your advance reservation 12345 has been granted

予約の削除にはqrdelコマンドを使います.予約した際に発行されたID(上の実行例の"12345")を引数として指定します.

shell-window-2
[xxxxxxxxxx@es1 ~]$ qrdel 12345

予約したリソースでジョブを実行

qsubコマンドに-arオプションで,予約した際に発行されたIDを指定します.

実行例:

shell-window-2
[xxxxxxxxxx@es1 ~]$ qsub -j y -cwd -l rt_F=1 -g $ID_GROUP -M $EMAIL -m besa -o $DIR_LOG -e $DIR_LOG -ar 12345 ./run.sh

おわりに

言い訳がましくて恐縮ですが,あくまで自分の用途に沿うように作ったメモを移植しただけなので,ABCIの使用方法を網羅しているわけではありません.より詳しい情報が必要な場合は「参考資料など」で挙げた資料を参照願います.

9
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
3