LoginSignup
11
9

More than 3 years have passed since last update.

Ubuntu20.04 へのSlurmのインストール (AWS EC2 Instance)

Last updated at Posted at 2021-03-28

はじめに

検証環境として Amazon EC2 のUbuntu20.04へ、Slurmをインストールすることになったので、その手順をメモします。

前提条件

今回は、Slurmのホストノード兼、debugキューを持つ計算ノードとします。そのため、下記2つのデーモンを起動します。

  • slurmctld
  • slurmd

ジョブのアカウンティング機能は今回設定しません、そのため、slurmdbd は起動していません。

参考情報

下記を参考にしました。一部、はまった部分もあるので、そこも含めてメモしておきます。オンプレでもたぶん一緒の手順でインストールできるとは思いますが、試してはいません。

Ubuntu20.04 の EC2インスタンスの起動

インスタンス起動

今回は下記のインスタンスを起動しました。 使用したAMIは ami-059b6d3840b03d6dd です。起動方法はここでは省略します。

image.png

パッケージのアップデート

いったん既存パッケージをアップデートしておきましょう。

command
sudo apt update

mungeのインストールと起動

mungeをインストールします。

libmunge-dev も必要ですので、忘れないようにしましょう。

command
sudo apt install -y munge libmunge-dev

mungeの起動確認

すでに起動していますが、念の為、mungeを再起動します。

command
sudo systemctl restart munge

起動状態を確認します。 以下のように active (running) になっていればOKです。

command
sudo systemctl status munge
response
● munge.service - MUNGE authentication service
     Loaded: loaded (/lib/systemd/system/munge.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-03-28 04:19:53 UTC; 1s ago
       Docs: man:munged(8)
    Process: 2019 ExecStart=/usr/sbin/munged (code=exited, status=0/SUCCESS)
   Main PID: 2022 (munged)
      Tasks: 4 (limit: 1160)
     Memory: 896.0K
     CGroup: /system.slice/munge.service
             └─2022 /usr/sbin/munged

Mar 28 04:19:53 ip-10-0-0-87 systemd[1]: Starting MUNGE authentication service...
Mar 28 04:19:53 ip-10-0-0-87 systemd[1]: Started MUNGE authentication service.

Slurm のインストール

関連パッケージのインストール

c言語環境が必要なので、下記gccをインストールします。これがないと、下記のconfigureの実行で怒られます。

command
sudo apt install -y build-essential

念の為、インストールがされたことを確認してみましょう

command
$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

パッケージのダウンロード

SchedMDのDownloadページ からパッケージをダウンロードし、ファイルを展開します。2021年3月28日現在、 slurm-20.11.5.tar.bz2 が最新でしたので、これを使います。ホームディレクトリー直下にダウンロードすることとします。

command
cd $HOME
wget https://download.schedmd.com/slurm/slurm-20.11.5.tar.bz2

パッケージの展開

パッケージを展開します。

command
tar -jxvf slurm-20.11.5.tar.bz2

インストール

configureによるインストール環境確認

./configure を実行して、インストール可能な環境か確認します。

  • mungeでトラブルが発生することが多かったので、念のため --with-munge=<'mungeインストールディレクトリ'> オプションを入れています。
  • オプションに関して、 ./configure --help でその詳細を確認できます。
  • 何かトラブルが出たときは、 configure.log の情報も確認してください

展開したパッケージへディレクトリーを移動します。

command
cd $HOME/slurm-20.11.5

mungeのインストールディレクトリーを調べます。この例では、 /usr/bin にmungeがインストールされています。

command
munge_dir=$(which munge) && echo ${munge_dir%/munge}
response
/usr/bin

下記の ${munge_dir%/munge}/usr/bin と直接いれてもかまいません。
mungeのインストールディレクトリーを指定しています。(多分、オプションなくても動きます。念のため)

command
./configure --with-munge="${munge_dir%/munge}"

Makefileが正しく作成されたことを確認しましょう。

command
$ ls -l Makefile
-rw-rw-r-- 1 ubuntu ubuntu 25199 Mar 28 04:50 Makefile

念のため、ここではmungeが正しく認識されていることを確認します。
mungeでトラブルが発生することが多かったので、うまくmungeを読み込めなかったときの状態も示しておきます。

GOOD
$ grep -i munge config.log
  $ ./configure --with-munge=/usr/bin
configure:20170: checking for munge installation
configure:20202: gcc -o conftest -g -O2 -fno-omit-frame-pointer -pthread -ggdb3 -Wall -g -O1 -fno-strict-aliasing    conftest.c -L/usr/lib64 -lmunge  -lm -lresolv  >&5
config.status:1672: creating src/plugins/auth/munge/Makefile
config.status:1672: creating src/plugins/cred/munge/Makefile
config.status:1978: cd src/plugins/auth/munge       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
config.status:1978: cd src/plugins/cred/munge       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
x_ac_cv_munge_dir=/usr
MUNGE_CPPFLAGS='-I/usr/include'
MUNGE_DIR='/usr'
MUNGE_LDFLAGS='-Wl,-rpath -Wl,/usr/lib64 -L/usr/lib64'
MUNGE_LIBS='-lmunge'
WITH_MUNGE_FALSE='#'
WITH_MUNGE_TRUE=''
BAD
$ grep -i munge config.log
  $ ./configure --with-munge=/usr/bin
configure:20170: checking for munge installation
configure:20218: WARNING: unable to locate munge installation
config.status:1672: creating src/plugins/auth/munge/Makefile
config.status:1672: creating src/plugins/cred/munge/Makefile
config.status:1978: cd src/plugins/auth/munge       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
config.status:1978: cd src/plugins/cred/munge       && sed -e '/# am--include-marker/d' Makefile         | make -f - am--depfiles
MUNGE_CPPFLAGS=''
MUNGE_DIR=''
MUNGE_LDFLAGS=''
MUNGE_LIBS=''
WITH_MUNGE_FALSE=''
WITH_MUNGE_TRUE='#'

makeコマンドによるslurmのコンパイルとインストール

command
make
command
sudo make install

Slurmの設定

slurm.conf の作成

Slurm Version 20.11 Configuration Tool - Easy Version のページから、slurm.confの雛形を作成してみましょう。

作成した雛形を、 /usr/local/etc/slurm.conf に保存します。

command
sudo vi /usr/local/etc/slurm.conf
内容
# slurm.conf file generated by configurator easy.html.
# Put this file on all nodes of your cluster.
# See the slurm.conf man page for more information.
#
SlurmctldHost=ip-10-0-0-87
#
#MailProg=/bin/mail
MpiDefault=none
#MpiParams=ports=#-#
ProctrackType=proctrack/pgid
ReturnToService=1
SlurmctldPidFile=/var/run/slurmctld.pid
#SlurmctldPort=6817
SlurmdPidFile=/var/run/slurmd.pid
#SlurmdPort=6818
SlurmdSpoolDir=/var/spool/slurmd
SlurmUser=root
#SlurmdUser=root
StateSaveLocation=/var/spool
SwitchType=switch/none
TaskPlugin=task/none
#
#
# TIMERS
#KillWait=30
#MinJobAge=300
#SlurmctldTimeout=120
#SlurmdTimeout=300
#
#
# SCHEDULING
SchedulerType=sched/backfill
SelectType=select/cons_tres
SelectTypeParameters=CR_Core
#
#
# LOGGING AND ACCOUNTING
AccountingStorageType=accounting_storage/none
ClusterName=cluster
#JobAcctGatherFrequency=30
JobAcctGatherType=jobacct_gather/none
#SlurmctldDebug=info
#SlurmctldLogFile=
#SlurmdDebug=info
#SlurmdLogFile=
#
#
# COMPUTE NODES
NodeName=ip-10-0-0-87 NodeAddr=10.0.0.87 CPUs=1 State=UNKNOWN
PartitionName=debug Nodes=ip-10-0-0-87 Default=YES MaxTime=INFINITE State=UP

slurmctld, slurmdの起動

先程、展開したslurmのパッケージの中に、etc/ のディレクトリーがあります。slurmをデーモン化するための設定ファイルがあるので、これを /etc/systemd/system/ 以下に保存します。

もし、展開したパッケージの中にいない場合は、下記を実行してください。

command
cd $HOME/slurm-20.11.5

ファイルをコピーします。

command
sudo cp etc/slurmctld.service /etc/systemd/system
sudo cp etc/slurmd.service /etc/systemd/system

Slurmを起動します。

command
sudo systemctl start slurmctld slurmd

Slurmが正しく確認したかどうかを調べます。ステータスが active (running) であることを確認してください。

command
sudo systemctl status slurmctld slurmd
response
● slurmctld.service - Slurm controller daemon
     Loaded: loaded (/etc/systemd/system/slurmctld.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-03-28 05:41:24 UTC; 5s ago
   Main PID: 92967 (slurmctld)
      Tasks: 7 (limit: 1160)
     Memory: 1.6M
     CGroup: /system.slice/slurmctld.service
             └─92967 /usr/local/sbin/slurmctld -D

Mar 28 05:41:24 ip-10-0-0-87 systemd[1]: Started Slurm controller daemon.

● slurmd.service - Slurm node daemon
     Loaded: loaded (/etc/systemd/system/slurmd.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-03-28 05:41:24 UTC; 5s ago
   Main PID: 92968 (slurmd)
      Tasks: 1 (limit: 1160)
     Memory: 1.1M
     CGroup: /system.slice/slurmd.service
             └─92968 /usr/local/sbin/slurmd -D

Mar 28 05:41:24 ip-10-0-0-87 systemd[1]: Started Slurm node daemon.

動作確認

command
$ sinfo -s
PARTITION AVAIL  TIMELIMIT   NODES(A/I/O/T) NODELIST
debug*       up   infinite          0/1/0/1 ip-10-0-0-87
command
$ srun -N 1 -n 1 hostname
ip-10-0-0-87
command
$ sbatch <<EOF
#!/bin/sh
#SBATCH -p debug
#SBATCH --job-name="test"
sleep 60
EOF
Submitted batch job 3
$ squeue
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
                 3     debug     test   ubuntu  R       0:19      1 ip-10-0-0-87

付録

遭遇したエラーのメモ

libmunge-dev のインストールし忘れで発生しました。

ubuntu@ip-10-0-0-87:~/slurm-20.11.5$ sudo systemctl status slurmctld slurmd
● slurmctld.service - Slurm controller daemon
     Loaded: loaded (/etc/systemd/system/slurmctld.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2021-03-28 05:21:42 UTC; 6s ago
    Process: 44026 ExecStart=/usr/local/sbin/slurmctld -D $SLURMCTLD_OPTIONS (code=exited, status=1/FAILURE)
   Main PID: 44026 (code=exited, status=1/FAILURE)

Mar 28 05:21:42 ip-10-0-0-87 systemd[1]: Started Slurm controller daemon.
Mar 28 05:21:42 ip-10-0-0-87 systemd[1]: slurmctld.service: Main process exited, code=exited, status=1/FAILURE
Mar 28 05:21:42 ip-10-0-0-87 systemd[1]: slurmctld.service: Failed with result 'exit-code'.

● slurmd.service - Slurm node daemon
     Loaded: loaded (/etc/systemd/system/slurmd.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2021-03-28 05:21:42 UTC; 6s ago
    Process: 44027 ExecStart=/usr/local/sbin/slurmd -D $SLURMD_OPTIONS (code=exited, status=1/FAILURE)
   Main PID: 44027 (code=exited, status=1/FAILURE)

Mar 28 05:21:42 ip-10-0-0-87 systemd[1]: Started Slurm node daemon.
Mar 28 05:21:42 ip-10-0-0-87 systemd[1]: slurmd.service: Main process exited, code=exited, status=1/FAILURE
Mar 28 05:21:42 ip-10-0-0-87 systemd[1]: slurmd.service: Failed with result 'exit-code'.
ubuntu@ip-10-0-0-87:~/slurm-20.11.5$ sudo /usr/local/sbin/slurmctld -D $SLURMCTLD_OPTIONS
slurmctld: error: High latency for 1000 calls to gettimeofday(): 552 microseconds
slurmctld: error: Configured MailProg is invalid
slurmctld: slurmctld version 20.11.5 started on cluster cluster
slurmctld: error: Couldn't find the specified plugin name for cred/munge looking at all files
slurmctld: error: cannot find cred plugin for cred/munge
slurmctld: error: cannot create cred context for cred/munge
slurmctld: fatal: slurm_cred_creator_ctx_create((null)): Operation not permitted
11
9
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
11
9