flagflag  If you want to see English page, please click "English" Button at Left.
ページ内コンテンツ

JupyterHub anchor.png

  • マルチユーザのための Jupyter サーバー(ユーザ認証機能つき)
Page Top

INSTALL anchor.png

Page Top

Rocky Linux 8 anchor.png

Page Top

pip anchor.png

 
Page Top

conda anchor.png

  • conda update -c conda-forge jupyterhub -y
     
Page Top

for CentOS 8.5 with pip anchor.png

# yum install python3
# pip3 install --upgrade pip
# yum install npm
# npm install -g configurable-http-proxy
# pip install setuptools_rust
# pip install jupyterhub
# pip install dockerspawner
# pip install --upgrade notebook
# pip install --upgrade jupyterlab
# jupyterhub --version
# jupyter --version
# jupyter notebook --version
# jupyter lab --version
 
Page Top

2.0.0 with conda anchor.png

Page Top
Install anchor.png
(base) # conda install -c conda-forge conda==4.11.0 -y
(base) # conda activate jupyterhub
(jupyterhub) # conda update -c conda-forge jupyterhub -y
(jupyterhub) # jupyterhub --upgrade-db
(jupyterhub) # jupyterhub -f .....
 
Page Top
podmanspawner.PodmanSpawner anchor.png
  • おおっ class のサンプルに Podman がある!
Page Top
websocket モジュールが無いとのことで起動しなくなった. anchor.png
ModuleNotFoundError: No module named 'websocket'
  • conda 環境で websocket をインストール
# conda install -c conda-forge websocket-client
  • pip なら pip install websockets 
     
Page Top
データベースのスキーマが合わないとのことで,起動しなくなった. anchor.png
  • jupyterhub upgrade-db してもだめなので,/var/lib/jupyterhub 以下を削除
     
Page Top

1.4.2 anchor.png

Page Top
conda を使用 anchor.png
(base) # conda create -n jupyterhub python=3.8 -y 
(base) # conda activate jupyterhub
(jupyterhub) # conda install -c conda-forge notebook -y
(jupyterhub) # conda install -c conda-forge jupyterlab -y
(jupyterhub) # conda install -c conda-forge jupyterhub==1.4.2  -y
(jupyterhub) # conda install -c conda-forge voila -y
(jupyterhub) # conda install jupyter_client -y

(jupyterhub) # git clone https://github.com/jupyterhub/nativeauthenticator.git 
(jupyterhub) # pip install -e nativeauthenticator   (認証モジュール:オプション)
(jupyterhub) # pip install dockerspawner
  • ディレクトリのパーミッションの設定を忘れずに!
     
Page Top
pip を使用する. anchor.png
  • nodejs: CentOS7 の場合は nodejs はバージョンが古くて,configurable-http-proxy でエラーが出るので,nodejs をバージョンアップする.
    curl -sL https://rpm.nodesource.com/setup_14.x | bash -
    yum remove nodejs npm -y
    yum install nodejs -y
    node -v
npm install -g configurable-http-proxy
python3 -m pip install jupyterhub
python3 -m pip install dockerspawner
python3 -m pip install --upgrade notebook
python3 -m pip install --upgrade jupyterlab 
 
Page Top

Notebook の Docker イメージ anchor.png

# docker pull jupyter/datascience-notebook
# docker pull jupyter/tensorflow-notebook
 
Page Top

Version Up 1.0.0 -> 1.4.1 anchor.png

 # conda install -c conda-forge jupyterhub
 # conda install notebook
Page Top
バージョンの確認 anchor.png
  • (jupyterhub) # jupyterhub --version
     
Page Top

LTI Authenticator anchor.png

  • Moodle と連携する為の 認証モジュール(Moodleの外部サービスを使用)
  • 先に authlib を入れておく.
    • conda install oauthlib or pip install oauthlib
(jupyterhub)# pip install --upgrade jupyterhub-ltiauthenticator
Page Top

設定 anchor.png

  • jupyterhub --generate-config を実行すると カレントディレクトリに設定ファイル jupyterhub_config.py が生成される.
  • 個人的には jupyterhub が /usr/local 以下にある場合は /usr/local/etc/jupyterhub 以下に置く.
  • 設定ファイルは拡張子が .py でないと,読み込まれない場合がある?
 
Page Top

Authenticator Class (authenticator_class) anchor.png

Page Top
auth.DummyAuthenticator anchor.png
  • その名の通りダミー.認証無し.
  • 全てのユーザを許可する.(一応パスワード入力欄は表示される)
     
Page Top
jupyterhub.auth.PAMAuthenticator (default) anchor.png
  • 認証にPAMを使用する.恐らくサービスは login
  • v1.1.0 にバグあり. Trouble Shooting 参照.
     
Page Top
nativeauthenticator.NativeAuthenticator anchor.png
  • 追加モジュール(オプション)
  • 詳細は検証中
     
Page Top
LDAP: ldapauthenticator.LDAPAuthenticator anchor.png
  • LDap 認証用.
  • モジュールのInstall
    (jupyterhub) # conda install -c conda-forge jupyterhub-ldapauthenticator -y
  • jupyterhub_config.py
    102 # for LDAP
    103 c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
    104 #c.LDAPAuthenticator.server_address = '202.26.150.*'
    105 c.LDAPAuthenticator.server_address = '202.26.144.*'
    106 c.LDAPAuthenticator.use_ssl = True
    107
    108 ## AD: template 付き(ユーザバインド)
    109 c.LDAPAuthenticator.lookup_dn = False
    110 c.LDAPAuthenticator.bind_dn_template = [
    111     'cn={username},ou=教員,ou=ユーザー,dc=edutuis,dc=local',
    112     'cn={username},ou=学生,ou=ユーザー,dc=edutuis,dc=local'
    113 ]
    114 c.LDAPAuthenticator.user_search_base = 'dc=edutuis,dc=local'
    115 c.LDAPAuthenticator.user_attribute = 'sAMAccountName'
    116
    117 ## AD: template なし
    118 #c.LDAPAuthenticator.lookup_dn = True
    119 #c.LDAPAuthenticator.user_search_base = 'dc=edutuis,dc=local'
    120 #c.LDAPAuthenticator.user_attribute = 'sAMAccountName'
    121 #c.LDAPAuthenticator.lookup_dn_search_user = 'cn=ldapauth,cn=users,dc=edutuis,dc=local'
    122 #c.LDAPAuthenticator.lookup_dn_search_password = '*****'
    123 #c.LDAPAuthenticator.lookup_dn_user_dn_attribute = 'cn'
    124
    125 ## NSL: username から dn が探せる場合(ユーザバインド)
    126 #c.LDAPAuthenticator.lookup_dn = False
    127 #c.LDAPAuthenticator.bind_dn_template = 'cn={username},ou=user,dc=nsl,dc=tuis,dc=ac,dc=jp'
    128
    129 ## NSL: ツリーを検索する場合
    130 #c.LDAPAuthenticator.lookup_dn = True
    131 #c.LDAPAuthenticator.user_search_base = 'ou=user,dc=nsl,dc=tuis,dc=ac,dc=jp'
    132 #c.LDAPAuthenticator.user_attribute = 'uid'
    133 #c.LDAPAuthenticator.lookup_dn_search_user = 'cn=Manager'
    134 #c.LDAPAuthenticator.lookup_dn_search_password = '*******'
    135 #c.LDAPAuthenticator.lookup_dn_user_dn_attribute = 'cn'
    136
Page Top
LTI モジュール anchor.png
 
Page Top

Server Class anchor.png

Page Top
jupyterhub.spawner.LocalProcessSpawner (default) anchor.png
  • LocalProcessSpawner
  • サーバに,各ユーザの環境でアクセスできる.
  • Jupiter Notebook はサーバにインストールされている物を使用する.
  • 通常作業ディレクトリは /home/{username}/notebook   (v1.0.0 はディレクトリ指定にバグが有る模様)
  • 使用ポートは 8000/tcp, 8081/tcp
     
Page Top
jupyterhub.spawner.SimpleLocalProcessSpa​wner anchor.png
  • 名前がややこしい
  • 詳細は不明(検証する気はあまりない)
     
Page Top
dockerspawner.DockerSpawner anchor.png
  • DockerSpawner
  • https://github.com/jupyterhub/dockerspaw​ner
  • サーバでユーザ毎に Docker でNotebook コンテナを起動して接続.
  • 作業ホームは /home/jovjan/work 固定(多分 Docker Image固定)
  • 使用ポートは 8000/tcp, 8081/tcp, 8001/tcp
  • Install
    (jupyterhub) # pip --no-cache-dir install git+https://github.com/jupyterhub/dockerspawner.git
    or
    (jupyterhub) # pip install dockerspawner
Page Top
dockerspawner.SystemUserSpawner anchor.png
  • dockerspawner.DockerSpawner からの派生クラス
  • DockerSpawner と同じパッケージ? 特にインストールしていないが,既に入っていた.
  • jovyan ではなく,ログインユーザで使用可.ログインユーザのホームディレクトリをマウントする.
  • ただしログインユーザの情報がローカルに取れない場合(LDAPのユーザバインドでログインした場合),ホームディレクトリ等の情報が無いので途中でエラーを起こす.
    • 作りこめば大丈夫かもしれん.
       
Page Top
dockerspawner.SwarmSpawner anchor.png
  • SwarmSpawner
  • dockerspawner.DockerSpawner からの派生クラス
  • DockerSpawner と同じパッケージ
  • クラスタリング用.
  • コンテナを Docker Compose で管理し,複数のサーバー上で実行できる.
  • 使用ポートは 8000/tcp, 8081/tcp, 8001/tcp, 2377/tcp, 7946/tcp, 7946/udp, 4789/udp
     
Page Top
niicloudoperation/jupyterhub-singleuser anchor.png
Page Top

jovyan って誰? anchor.png

Page Top

実行 anchor.png

Page Top
前準備 anchor.png
# cd /etc/pki/tls
# openssl req -new -newkey rsa:2048 -days 3650 -nodes -keyout private/key.pem -out server.csr
# openssl x509 -in server.csr -days 3650 -req -signkey private/key.pem -out certs/server.pem
# vi  /usr/local/etc/jupyterhub/jupyterhub_config.py

# mkdir /var/lib/jupyterhub
Page Top
実行 anchor.png
(base) # conda activate jupyterhub
(jupyterhub) # jupyterhub -f /usr/local/etc/jupyterhub/jupyterhub_config.py
  • --no-ssl は0.7で廃止された
     
Page Top

Log anchor.png

Page Top

LC_nblineage anchor.png

Page Top

情報ソース anchor.png

Page Top

Notebook anchor.png

Page Top
Docker Images anchor.png
Page Top
niicloudoperation/notebook anchor.png
  • docker pull niicloudoperation/notebook
     
Page Top

Spawner anchor.png

Page Top

DB anchor.png

Page Top

MySQL anchor.png

  • SQLAlchemy で PyMySQL ドライバを使用する
  • pool_recycle の設定を忘れずに!
  • charset は urf8mb4
     
Page Top

NVIDIA anchor.png

Page Top

Driver anchor.png

Page Top
nouveau ドライバ(デフォルトのグラフィックドライバ)を止める anchor.png
  • lsmod | grep nouveau でドライバ確認
  • /etc/default/grab のオプションに rd.driver.blacklist=nouveau を追加
  • カーネル設定ファイルの作り直し
    • grub2-mkconfig -o /boot/grub2/grub.cfg (RedHat系)
    • grub-mkconfig -o /boot/grub/grub.cfg (Debian系)
       
Page Top
Driver anchor.png
  • nvidia-driver, cuda をインストール
     
Page Top
Docker anchor.png
  • nvidia-container-toolkit が必要
    • コンテナ内からホストのGPUを使う
    • nvidia-smi などのコマンドがインストールされる.
       
Page Top

Tool Kit anchor.png

Page Top

Docker anchor.png

  • docker run --gpus all nvidia/cuda:12.2.0-devel-ubuntu20.04 nvidia-smi
    • Failed to initialize NVML: Unknown Error
    • ホストの /etc/nvidia-container-runtime/config.tom​l を編集して,no-cgroups = false にする.
       
Page Top

Trouble Shooting anchor.png

Page Top
Jupyterhub 4.0.0 anchor.png
  • 403 : Forbidden '_xsrf' argument missing from POST のエラー
    • JupyterHub で XSRFのチェックを強化したらしい
  • /usr/local/lib/python3.9/site-packages/j​upyterhub/handlers/base.py
    • def check_xsrf_cookie(self)
      • super().check_xsrf_cookie() で例外発生
      • 親は tornado のRequestHandlerか?
  • 2023 5/29 時点でこのバグは修正されている.
     
Page Top

JupyterLab anchor.png

Page Top
JupyterHub をバージョンアップしたら Jupyter Labが起動しなくなった. anchor.png
  • 起動する JupyterHub(ex. 2.0.1)とイメージ内のJupyterHub(ex. 1.4.1)が違うとデフォルトで Jupyter Labが起動しなくなるようだ.
     
Page Top

日本語のBUG anchor.png

  • 日本語のファイルやディレクトリでコピーなどを行うと errno 13 のエラーが起きる.でもコピーはちゃんと行われる.エラーを消したい.
     
Page Top

PAM anchor.png

Page Top
JupyterHub: PAM使用時に 再login するとPAMの認証エラーになる. anchor.png
  • 認証モジュールに jupyterhub.auth.PAMAuthenticator を使用した場合,再Loginで失敗
    • c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
  • バグだろ.
  • Resolve: jupyterhub_config.py に c.PAMAuthenticator.open_sessions = False を追加する
  • see: https://github.com/jupyterhub/jupyterhub​/issues/486
     
Page Top
swarm モードだと v1.1.0 でPAM認証のエラーを起こす. anchor.png
  • 上記バグもこれか?
  • 1.0.0 に戻す.
    (jupyterhub) # conda uninstall jupyterhub
    (jupyterhub) # conda -c conda-forge install jupyterhub==1.0.0
     
Page Top

homeディレクトの名前を変えたら,ログインできなくなった anchor.png

  • /.cache, ~/.jupyter, ~/.local ができているので消す.

     
Page Top

Programing anchor.png

Page Top
docker anchor.png
Page Top
podman anchor.png
 

トップ   凍結 差分 バックアップ 複製 名前変更 リロード   新規 ページ一覧 単語検索 最終更新   ヘルプ   最終更新のRSS 1.0 最終更新のRSS 2.0 最終更新のRSS Atom
Counter: 2112, today: 1, yesterday: 2
最終更新: 2023-12-04 (月) 11:30:44 (JST) (136d) by iseki

サイト内 検索

ログイン

ユーザー名:

パスワード:


パスワード紛失
新規登録

サブ メニュー

ミニカレンダー

前月2024年 4月翌月
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
<今日>

オンライン状況

47 人のユーザが現在オンラインです。 (7 人のユーザが xpwiki を参照しています。)

登録ユーザ: 0
ゲスト: 47

もっと...

アクセスカウンタ

今日 : 1140114011401140
昨日 : 8008800880088008
総計 : 2327677623276776232767762327677623276776232767762327677623276776
Powered by XOOPS Cube 2.1© 2001-2006 XOOPS Cube Project
Design by XoopsDesign.com