本家様 https://jupyter.org/

「JupyterLab」と「Jupyter Notebook」があるようです. RのR/RStudioServerR/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は有償の場合があります

2024y08m07d_005601565.png

っで枠組みを作ります

[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」を追加することで利用可能になります。

jupyterlab

ここでは簡単に 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を開けてください
2024y08m11d_010822272.png 2024y08m11d_011146284.png

ブラウザ経由でアクセスして、notebookのように実行した行が残ります。ファイルは自分のホームディレクトリ配下に置けます

使い終わったらターミナルでCtrl-cで抜けますかと問われ、[y]と打つと停止します
一台の計算機を個人で使用するならいいですが、複数人で使うなら使用ポートの調整とあと各自のjupyterlabにパスワードを付与することが必要かと.

Jupyter Notebook

ほぼほぼ 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」と同じにブラウザでアクセスするのですが、アクセス直後の画面が下記になります。
2024y08m11d_014352525.png

先ほどテストしたときに柵瀬資された「Untitledipynb」ファイルをクリックすると新たなタブが現れ下記を表示します
2024y08m11d_014517621.png

IPythonの進化系って感じです。より高機能のJupyterLabでいいような気がします。

めも

ブラウザで操作するものなので、基本自分のmacOS/windows(WSL)で環境を作って動かした方がいいのかなと思っている
大きい計算機で利用する手もあるけど、その際はport占有の許可、パスワードロックの付与とか手間が増えそうな気がします。

最新の60件
2025-01-13 2025-01-12 2025-01-08 2024-12-30 2024-12-29 2024-12-24 2024-12-22 2024-12-20 2024-12-17 2024-12-15 2024-12-14 2024-12-12 2024-12-11 2024-12-10 2024-12-09 2024-12-08 2024-12-04 2024-11-28 2024-11-22 2024-11-15 2024-11-14 2024-11-12 2024-11-06 2024-11-05 2024-11-04 2024-11-02 2024-11-01 2024-10-29 2024-10-28 2024-10-27 2024-10-23 2024-10-18 2024-10-17 2024-10-15 2024-10-14 2024-10-13 2024-10-11 2024-10-10 2024-10-09 2024-10-08 2024-10-05 2024-10-04 2024-10-03

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2024-08-14 (水) 01:23:35