1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

RHEL on Power10 に micromambaを導入し RocketCE を設定して仮想環境に pytorch-cpuと JupyterLab を導入

Last updated at Posted at 2024-04-05

はじめに

RHEL on Power10 に micromambaを導入し RocketCEを設定して仮想環境に pytorch-cpuと JupyterLab を導入したログです。

以下を参考にしています。


RocketCEとは?

RocketCE for Power

RocketCEは、IBM Powerアーキテクチャ用に構築およびサポートされているCognitive Environment(CE)バイナリのセットです。


micromamba とは?

Micromamba User Guide

micromambaはパッケージマネージャの小さなバージョンです。静的にリンクされたC++実行ファイルで、独立したコマンドラインインターフェイスを持っています。環境を必要とせず、Pythonのデフォルトバージョンも付属していません。


環境

RHEL 9.2 LPAR on IBM Power S1022
 (GPU ではなくPower10 CPUの環境です)


micromamba 導入

・RHEL9 Base, AppStream の yum リポジトリーを設定しています。

# yum repolist
Updating Subscription Management repositories.
repo id                                   repo name
rhel-9-for-ppc64le-appstream-rpms         Red Hat Enterprise Linux 9 for Power, 
  little endian - AppStream (RPMs)
rhel-9-for-ppc64le-baseos-rpms            Red Hat Enterprise Linux 9 for Power, 
  little endian - BaseOS (RPMs)

・bzip2 libxcrypt-compat vim の導入を実行

# dnf install bzip2 libxcrypt-compat vim -y

・micromamba 導入を実行

#  "${SHELL}" <(curl -L micro.mamba.pm/install.sh)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3070  100  3070    0     0   6573      0 --:--:-- --:--:-- --:--:--  6573
Micromamba binary folder? [~/.local/bin]
Init shell (bash)? [Y/n] y
Configure conda-forge? [Y/n] y
Prefix location? [~/micromamba]
Modifying RC file "/root/.bashrc"
Generating config for root prefix "/root/micromamba"
Setting mamba executable to: "/root/.local/bin/micromamba"
Adding (or replacing) the following in your "/root/.bashrc" file

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE='/root/.local/bin/micromamba';
export MAMBA_ROOT_PREFIX='/root/micromamba';
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__mamba_setup"
else
    alias micromamba="$MAMBA_EXE"  # Fallback on help from mamba activate
fi
unset __mamba_setup
# <<< mamba initialize <<<

Please restart your shell to activate micromamba or run the following:\n
  source ~/.bashrc (or ~/.zshrc, ~/.xonshrc, ~/.config/fish/config.fish, ...)

~/.bashrc の編集。仮想環境 "base" をログイン時に起動する設定を追加

# echo "micromamba activate base" >> ${HOME}/.bashrc

~/.bashrc の中身を確認

# cat ~/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

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

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE='/root/.local/bin/micromamba';
export MAMBA_ROOT_PREFIX='/root/micromamba';
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__mamba_setup"
else
    alias micromamba="$MAMBA_EXE"  # Fallback on help from mamba activate
fi
unset __mamba_setup
# <<< mamba initialize <<<
micromamba activate base

~/.bashrc の読み込み

# source ${HOME}/.bashrc

~/.condarc の設定。rocketce、defaults チャネルを記載

(base) # cat >> ~/.condarc <<'EOF'
> # Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
> auto_update_conda: false
> show_channel_urls: true
> channel_priority: flexible
> channels:
>   - rocketce
>   - defaults
> EOF
(base) #

仮想環境 "base" に python, pytorch-cpu 導入

試行錯誤して以下の実行で python, mamba, conda, pip, pytorch-cpu を仮想環境 baseへの導入可能を確認

① python 3.11, mamba, を導入

(base) # micromamba install --yes python=3.11  mamba

この状態で conda pip が導入されていました。

(base) # which conda
/root/micromamba/bin/conda
(base) # which pip
/root/micromamba/bin/pip

② channel を指定して pytorch-cpu を導入

(base) # micromamba install pytorch-cpu  -c rocketce -c defaults

pytorch バージョンの確認

(base) # python -c 'import torch; print(torch.__version__)'
2.0.1

2.0.1 が出力しました。無事 torch が使用できるようになりました。


仮想環境 "base" に jupyterlab 導入

① 仮想環境 "base" に jupyterlab を導入
  (conda コマンドを使用)

(base) # conda install --yes jupyterlab

-> 30秒程度で導入完了

ちなみに ~/.condarc がいつの間にか編集されたので以下のように修正しています。

# cat ~/.condarc
# Conda configuration see https://conda.io/projects/conda/en/latest/configuration.html
auto_update_conda: false
show_channel_urls: true
channel_priority: flexible
channels:
  - rocketce
  - defaults
  - conda-forge

② notebooks ディレクトリを作成

(base) # mkdir notebooks

③ jupyterlab 起動

(base) # nohup jupyter lab --notebook-dir=${HOME}/notebooks 
 --ip=0.0.0.0 --no-browser --allow-root --port=8888 --NotebookApp.allow_origin='*' 
  --NotebookApp.token='' --NotebookApp.password='' &

④ 別ターミナルでLocal環境にポートフォワーディングを実行

### 別ターミナルで実行 ###

$ ssh -i id_rsa_xxx root@<対象サーバー> -L 8888:localhost:8888

⑤ jupyterlab をLocal環境のブラウザで表示

http://localhost:8888/lab で以下が表示されました。

スクリーンショット 2024-04-05 21.56.28.png


参考にしたブログの手順通りに進まなかったので多少試行錯誤して上の内容を確認しました。
バージョンが少し変わるとすぐに手順が変わってしまいますね...

以上です。

1
1
3

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?