public_notes/content/20240310135606 raspberry piにjupyterhubをインストール.md

108 lines
3.5 KiB
Markdown
Raw Normal View History

2024-05-23 15:15:03 +09:00
# 20240310135606 raspberry piにjupyterhubをインストール
2024-03-11 16:45:11 +09:00
#raspi #jupyter #jupyterhub
[[20240121125457 venv|venv]] で作ったローカル環境にインストールした。
## npmとconfigurable-http-proxyのインストール
これもローカル環境をつくった方がよかったかも
```
$ sudo apt install npm
$ sudo npm install configurable-http-proxy
```
## jupyterhubをインストール
venvを有効にして、jupyter, jupyterhubをインストール
```
2024-05-23 15:15:03 +09:00
$ sudo apt install gcc python3-dev # 依存関係。自分の場合はこれが足りていなくて、pip installでコケた
2024-03-11 16:45:11 +09:00
$ mkdir jupyter
$ cd jupyter
2024-05-23 15:30:02 +09:00
$ python -m venv venv
$ . venv/bin/activate
2024-05-23 15:15:03 +09:00
(venv) $ pip install jupyter jupyterhub
2024-03-11 16:45:11 +09:00
```
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)
2024-04-26 17:30:13 +09:00
- [JupyterHub/JupyterLabを構築してみた マルチユーザでGPUマシンを共有するための開発環境トレンドコラムGPUサーバープラットフォームの設計/構築なら「技術力」のNTTPC](https://www.nttpc.co.jp/gpu/article/technical12.html)
### 未整理
#tech #server #raspi
https://github.com/jupyterhub/jupyterhub-the-hard-way/blob/HEAD/docs/installation-guide-hard.md
[Raspberry Pi 4 ModelBでJupyterLabを使うみなみゆうき](https://note.com/y373/n/ne5f96936fc28)
[JupyterHub + JupyterLabで Python マルチユーザプラットフォームを作る on Rapsberry Pi 3B+ ! #Python - Qiita](https://qiita.com/noguhiro2002/items/99758ad66587f24c0ef2)
https://blog.gitea.com/render-jupyter-notebooks/
configurable-http-proxy
giteaで表示したい
sudo apt install jupyter-nbconvert ipython3 python3-ipykernel
sudo ipython3 kernel install --name "python3"
これを踏む
[exporting matplotlib plots to html when using %matplotlib widget or notebook · Issue #1655 · jupyter/nbconvert · GitHub](https://github.com/jupyter/nbconvert/issues/1655)
たぶんこっちの方がいい voila
[GitHub - voila-dashboards/voila: Voilà turns Jupyter notebooks into standalone web applications](https://github.com/voila-dashboards/voila)