「JupyterLab」と「Jupyter Notebook」があるようです. RのR/RStudioServerとR/RStudioなものかな
JupyterLab: A Next-Generation Notebook Interface
JupyterLab is the latest web-based interactive development environment for notebooks, code, and data.
Its flexible interface allows users to configure and arrange workflows in data science, scientific computing, computational journalism, and machine learning.
A modular design invites extensions to expand and enrich functionality.
(deepL翻訳:JupyterLabは、ノートブック、コード、データのための最新のウェブベースのインタラクティブな開発環境です。
その柔軟なインターフェースにより、ユーザーはデータサイエンス、科学計算、計算ジャーナリズム、機械学習におけるワークフローを設定し、アレンジすることができる。
モジュール式の設計により、機能の拡張や充実が可能です。)
Jupyter Notebook: The Classic Notebook Interface
The Jupyter Notebook is the original web application for creating and sharing computational documents. It offers a simple, streamlined, document-centric experience.
(deepL翻訳:Jupyter Notebookは、計算ドキュメントを作成・共有するためのオリジナルのウェブアプリケーションです。シンプルで合理的な、ドキュメント中心の体験を提供します。)
ここでは pyenv を敷いてその上に anaconda や必要に応じて miniforge を入れ、さらにその上に python 実行環境を用意しています。 anacondaは有償の場合があります
っで枠組みを作ります
[root@rockylinux9 ~]# cat /etc/redhat-release
Rocky Linux release 9.4 (Blue Onyx)
[root@rockylinux9 ~]# git clone https://github.com/yyuu/pyenv.git /apps/pyenv
[root@rockylinux9 ~]# export PYENV_ROOT=/apps/pyenv
[root@rockylinux9 ~]# export PATH=$PYENV_ROOT/bin:$PATH
[root@rockylinux9 ~]# pyenv install --list <--これでanaconda,minicondaのバージョンが一覧されます.
[root@rockylinux9 ~]# pyenv install anaconda3-2024.06-1
[root@rockylinux9 ~]# pyenv global anaconda3-2024.06-1
[root@rockylinux9 ~]# source /apps/pyenv/versions/anaconda3-2024.06-1/etc/profile.d/conda.sh
[root@rockylinux9 ~]# conda env list
# conda environments:
#
base /apps/pyenv/versions/anaconda3-2024.06-1
[root@rockylinux9 ~]#
この後に「conda create -n <環境名> python ..」とかで実行環境を用意します。
JupyterLabやJupyter Notebookはこの実行環境に「jupyterlab」「jupyter」を追加することで利用可能になります。
ここでは簡単に PyTorch の実行環境を擁してそこにjupyterlab を組み込んで使ってみます
[illya@rockylinux9 ~]$ source /apps/pyenv/versions/anaconda3-2024.06-1/etc/profile.d/conda.sh
[illya@rockylinux9 ~]$ conda create -n pytorch-jupyterlab pytorch
:
environment location: /home/illya/.conda/envs/pytorch-jupyterlab
:
[illya@rockylinux9 ~]$ conda activate pytorch-jupyterlab
(pytorch-jupyterlab) [illya@rockylinux9 ~]$ conda install jupyterlab -c conda-forge *conda-forgeチャンネルのjupyterlabを推奨しているみたい
[あるいは]
pip install jupyterlab
(pytorch-jupyterlab) [illya@rockylinux9 ~]$ jupyter --version
Selected Jupyter core packages...
IPython : 8.26.0
ipykernel : 6.29.5
ipywidgets : not installed
jupyter_client : 8.6.2
jupyter_core : 5.7.2
jupyter_server : 2.14.2
jupyterlab : 4.2.4
nbclient : 0.10.0
nbconvert : 7.16.4
nbformat : 5.10.4
notebook : not installed
qtconsole : not installed
traitlets : 5.14.3
(pytorch-jupyterlab) [illya@rockylinux9 ~]$
これで PyTorch 実行環境「pytorch-jupyterlab」にjupyterlabの組み込みが完了しました
使うには 実行環境「pytorch-jupyterlab」内で「jupyter lab」と実行します。その前に設定を変更します。このまま起動すると起動マシンのみアクセス可能で他からアクセスできないので。
(pytorch-jupyterlab) [illya@rockylinux9 ~]$ jupyter lab --generate-config
Writing default config to: /home/illya/.jupyter/jupyter_lab_config.py
(pytorch-jupyterlab) [illya@rockylinux9 ~]$ vi /home/illya/.jupyter/jupyter_lab_config.py
:
c.ServerApp.ip = '*'
:
(pytorch-jupyterlab) [illya@rockylinux9 ~]$
その後に起動させます
(pytorch-jupyterlab) [illya@rockylinux9 ~]$ jupyter lab
:
To access the server, open this file in a browser:
file:///home/illya/.local/share/jupyter/runtime/jpserver-9459-open.html
Or copy and paste one of these URLs:
http://localhost:8888/lab?token=27a319643edf0aa2e156c43be5c84a58b7623475156266cf
http://127.0.0.1:8888/lab?token=27a319643edf0aa2e156c43be5c84a58b7623475156266cf
:
ターミナルかフォアグラウンドのままですが、ここでブラウザを起動させ対象マシンのホスト名配下に「:8888/lab?token=27a319643edf0aa2e156c43be5c84a58b7623475156266cf」を加えてアクセスします
*firewallが動いていたら無効にするか8888/tcpを開けてください
ブラウザ経由でアクセスして、notebookのように実行した行が残ります。ファイルは自分のホームディレクトリ配下に置けます
使い終わったらターミナルでCtrl-cで抜けますかと問われ、[y]と打つと停止します
一台の計算機を個人で使用するならいいですが、複数人で使うなら使用ポートの調整とあと各自のjupyterlabにパスワードを付与することが必要かと.
ほぼほぼ jupyterlab でいいような気がしますが、こちらも。
すでにjupyterlabが入っている実行環境「pytorch-jupyterlab」にJupyter Notebookの機能も載せたいと思います
(pytorch-jupyterlab) [illya@rockylinux9 ~]$ conda install notebook -c conda-forge
(pytorch-jupyterlab) [illya@rockylinux9 ~]$ jupyter --version
Selected Jupyter core packages...
IPython : 8.26.0
ipykernel : 6.29.5
ipywidgets : not installed
jupyter_client : 8.6.2
jupyter_core : 5.7.2
jupyter_server : 2.14.2
jupyterlab : 4.2.4
nbclient : 0.10.0
nbconvert : 7.16.4
nbformat : 5.10.4
notebook : 7.2.1
qtconsole : not installed
traitlets : 5.14.3
(pytorch-jupyterlab) [illya@rockylinux9 ~]$
っと「notebook」のこうもくが埋まりました。っで起動します. 起動コマンドは「jupyter notebook」です
(pytorch-jupyterlab) [illya@rockylinux9 ~]$ jupyter notebook
:
To access the server, open this file in a browser:
file:///home/illya/.local/share/jupyter/runtime/jpserver-11007-open.html
Or copy and paste one of these URLs:
http://localhost:8888/tree?token=a3899221f7fc59945989ee7c3198cd178af27ca6841bd067
http://127.0.0.1:8888/tree?token=a3899221f7fc59945989ee7c3198cd178af27ca6841bd067
:
これも「jupyterlab」と同じにブラウザでアクセスするのですが、アクセス直後の画面が下記になります。
先ほどテストしたときに柵瀬資された「Untitledipynb」ファイルをクリックすると新たなタブが現れ下記を表示します
IPythonの進化系って感じです。より高機能のJupyterLabでいいような気がします。
ブラウザで操作するものなので、基本自分のmacOS/windows(WSL)で環境を作って動かした方がいいのかなと思っている
大きい計算機で利用する手もあるけど、その際はport占有の許可、パスワードロックの付与とか手間が増えそうな気がします。