84 lines
No EOL
2.4 KiB
Markdown
84 lines
No EOL
2.4 KiB
Markdown
# 20240310135606 raspi4にjupyterhubをインストール
|
||
#raspi #jupyter #jupyterhub
|
||
[[20240121125457 venv|venv]] で作ったローカル環境にインストールした。
|
||
|
||
## npmとconfigurable-http-proxyのインストール
|
||
これもローカル環境をつくった方がよかったかも
|
||
```
|
||
$ sudo apt install npm
|
||
$ sudo npm install configurable-http-proxy
|
||
```
|
||
|
||
## jupyterhubをインストール
|
||
venvを有効にして、jupyter, jupyterhubをインストール
|
||
```
|
||
$ mkdir jupyter
|
||
$ cd jupyter
|
||
$ python -m venv .venv
|
||
$ . .venv/bin/activate
|
||
(venv) $ sudo pip install jupyter jupyterhub
|
||
```
|
||
|
||
jupyterhubの設定ファイルを作成
|
||
```
|
||
(venv) $ jupyterhub --generate-config
|
||
```
|
||
|
||
いくつかの項目を編集した
|
||
```
|
||
c.JupyterHub.bind_url = 'http://:8000/jupyter'
|
||
c.Spawner.cmd = ['/home/kazbo/jupyter/venv/bin/jupyterhub-singleuser']
|
||
c.Spawner.default_url = '/lab'
|
||
c.Authenticator.admin_users = {'kazbo'}
|
||
c.Authenticator.allowed_users = {'kazbo'}
|
||
```
|
||
|
||
起動
|
||
```
|
||
(venv) $ jupyterhub
|
||
```
|
||
|
||
ログイン画面が表示されればOK。
|
||
|
||
## nginxへの追加
|
||
こんな感じにしてある。
|
||
```
|
||
location /jupyter/ {
|
||
# NOTE important to also set base url of jupyterhub to /jupyter in its config
|
||
proxy_pass http://127.0.0.1:8000;
|
||
|
||
proxy_redirect off;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
|
||
# websocket headers
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection $connection_upgrade;
|
||
|
||
}
|
||
```
|
||
## サービス化
|
||
venv配下のpythonとかjupyterhubとかを単純に呼べばvenvが実行されるっぽい。
|
||
```
|
||
[Unit]
|
||
Description=jupyterhub
|
||
After=syslog.target
|
||
After=network.target
|
||
|
||
[Service]
|
||
WorkingDirectory=/home/kazbo/jupyter
|
||
|
||
|
||
ExecStart=/home/kazbo/jupyter/venv/bin/jupyterhub -f /home/kazbo/jupyter/jupyterhub_config.py
|
||
Restart=no
|
||
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
||
```
|
||
|
||
## Refs.
|
||
- [Project Jupyter | JupyterHub](https://jupyter.org/hub)
|
||
- [JupyterHub/JupyterLabを構築してみた ~マルチユーザでGPUマシンを共有するための開発環境~|トレンドコラム|GPUサーバープラットフォームの設計/構築なら「技術力」のNTTPC](https://www.nttpc.co.jp/gpu/article/technical12.html) |