0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【tsubame】jupyterlabのカーネルを作るための関数

Last updated at Posted at 2022-10-20

ぼくがかんがえたさいきょうのかすたむかーねるさくせいかんすう

東工大のスパコンtsubameではwebサービスとしてjupyterlabを使うことができます。
jupyterlab上で使えるpythonのバージョンがデフォルトの3.6.5のみかと思い込んでいましたが、どうやらt3jpttoolsモジュールを使ってカスタムカーネルを作成することでバージョンを変更できるようです。
Jupyter Lab 利用の手引き

ということで一発で所望のカスタムカーネルを作る関数を書きました。

create_kernel.py
import sys
from t3jpttools import create_kernel

def main():
    """
    create kernel with modules that you want to use.
    """
    print("#################################################")
    print('Be sure that your virtual env has been activated.')
    print('#################################################')
    args = sys.argv
    name = str(args[1]) # 実行しているpyファイルの名前が第一コマンドライン引数
    module_list = args[2:]
    modules =''
    modules = ' '.join(module_list)
    print(f'kernel name : {name} / modules : {module_list}')
    create_kernel(name, modules)
    print('done!!')

if __name__ == '__main__':
    main()

実行例

Terminal
python create_kernel.py test_kernel jupyterlab/2.1.0-py383 cuda/10.2.89 cudnn/7.6 nccl/2.4.2

jupyterlab/2.1.0-py383を指定することでjupyterlab上でのpythonのバージョンが3.8.3になります。選択肢としては3.8.3か3.6.5しかないようです。
ちなみに使えるモジュールについてはmodule availでリストを表示することで確認できます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?