Skip to content

Hyades

JASMINE チームで使用している共用計算機 Hyades の初期設定について記述します. OS は Ubuntu がインストールされています.

Console setting

~/.bash_aliases に以下の設定を追加しました.

#!/bin/bash

export PAGER="less"

alias emacs='emacs -nw'

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'

Git setting

Git の基本設定をします. global 設定の内容は以下のとおりです.

$ git config -l --global
user.name=Ryou Ohsawa
[email protected]
push.default=simple
color.ui=true
alias.wdiff=diff --word-diff
alias.cdiff=diff --word-diff --word-diff-regex=.
alias.tree=log --graph --oneline --exclude=refs/remotes/origin/gh-pages --all
diff.wserrorhighlight=all
core.editor=vi
pull.ff=only
fetch.prune=true
pager.log=less
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process

Install Python

pyenv で好みのバージョンの Python をインストールします. Python の build に必要なパッケージを追加でインストールしました.

$ sudo apt install build-essential \
    libzma-dev libncursesw5-dev libreadline-dev \
    libsqlite3-dev libssl-dev tk-dev libgdbm-dev libc6-dev \
    libbz2-dev liblzma-dev libffi-dev

GitHub から pyenv を clone します. 慣習に倣って .pyenv ディレクトリを作成しました. また pluginspyenv-virtualenv を clone して virtualenv を使えるようにしておきます.

$ git clone https://github.com/pyenv/pyenv.git .pyenv
$ cd .pyenv/plugins/
$ git clone https://github.com/pyenv/pyenv-virtualenv.git

~/.bash_pyenv というファイルを作成して pyenv を有効にするための設定を記述します.

#!/bin/bash

export PYENV_ROOT="/home/rohsawa/.pyenv/"
export PATH="${PYENV_ROOT}/bin:${PATH}"

eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

~/.bashrc に以下の設定を追記して設定が自動で読み込まれるようにします. ターミナルを再起動して pyenv コマンドが使えるようになっていることを確認しておきます.

if [ -f ~/.bash_pyenv ]; then
    . ~/.bash_pyenv
fi

今回は Python 3.11.3 をインストールしました.

$ pyenv install 3.11.3
$ pyenv global 3.11.3
$ pip install --upgrade pip

Setup CUDA

Hyades には GPU が搭載されています. GPU 計算で使用するためのライブラリ CUDA がインストールされていましたが, バージョンが古かったので新しいものをインストールしました. NVIDIA Developer からCUDA Toolkit をダウンロードします. このサイトにアクセスすると最新の CUDA Toolkit がダウンロードできます.

cuDNN のダウンロードにはユーザ登録が必要です. メールアドレスを登録して必要なバージョンの cuDNN をダウンロードします. Ubuntu であれば deb package を選択しておきます.

ダウンロードしたファイルをそれぞれ /usr/local/src に置きます.

CUDA のインストール中には X server が動いているとエラーになります. そこで起動オプションで graphical terminal が起動しないように設定して再起動しました. /etc/default/grub を以下のように編集します.

--- /etc/default/grub.orig
+++ /etc/default/grub
@@ -11,17 +11,17 @@
 GRUB_CMDLINE_LINUX=""

 # Uncomment to enable BadRAM filtering, modify to suit your needs
 # This works with Linux (no patch required) and with any kernel that obtains
 # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
 #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

 # Uncomment to disable graphical terminal (grub-pc only)
-GRUB_TERMINAL=console
+# GRUB_TERMINAL=console

 # The resolution used on graphical terminal
 # note that you can use only modes which your graphic card supports via VBE
 # you can see them in real GRUB with the command `vbeinfo'
 #GRUB_GFXMODE=640x480

 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
 #GRUB_DISABLE_LINUX_UUID=true

変更を反映させて再起動します. 詳細は Boot Ubuntu 22.04 in text mode を参照してください.

# update-grub
# systemctl set-default multi-user.target
# reboot -n

ログインしたら以下の手順でダウンロードしたパッケージをインストールします. CUDA のバージョンは 11.8 と 12.1 が利用可能でしたが, 使いたい Python パッケージが CUDA 12 系に対応していなかったので 11.8 をインストールしました.

# sh cuda_11.8.0_520.61.05_linux.run
# cp /var/cudnn-local-repo-ubuntu1804-8.9.1.23/cudnn-local-569BAFC7-keyring.gpg /usr/share/keyrings/
# dpkg -i cudnn-local-repo-cuda11-ubuntu1804-8.9.1.23_1.0-1_amd64.deb

忘れずに /etc/default/grub を元に戻して再起動します. 以下のコマンドで適切なバージョンの CUDA が認識されていることを確認します.

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

$ nvidia-smi
Sun Oct 15 15:01:46 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 520.61.05    Driver Version: 520.61.05    CUDA Version: 11.8     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:17:00.0 Off |                  N/A |
| 30%   44C    P0    91W / 350W |      0MiB / 24576MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

Last update: October 15, 2023