1
0

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 1 year has passed since last update.

vscode でリモートサーバ側で Jupyter とかの Python の REPL 環境整備するメモ

Last updated at Posted at 2023-01-08

背景

つよつよ GPU サーバー上で Python 機械学習コードとか REPL で動かしたい.
torch とかで 10 GB とかモデルサイズあるようなのだと起動だけで 10 秒くらい時間かかってしまうので, .py 単体実行してデバッグとかが向かないようなケース.

Jupyterlab 的に matplotlib でプロットとかもしたい.

Jupyterlab をサーバで動かして, vscode で繋ぐというのが検索するとよく出てきますが,
token とかのセットアップめんどいし, Python 環境自体はローカル環境側しか使ってくれないっぽいようでうまくいかないことがわかりました.

リモート側で vscode 建てると, 今度は X11 画面転送遅いし...

方法

一旦 ssh でリモート側に繋いで, リモート側で一式やるのが良いことがわかりました!

ローカル側で, Remote ssh とか, Jupyterlab とか, Python とかの Extension を一式いれておきます.
(Windows 使っている方は, WSL 接続でこの当たり十分経験しているかと思います)

リモート側も Jupyterlab とか conda or pip で入れておきます.

サーバに ssh 接続

Screenshot from 2023-01-08 21-14-48.png

Ctrl + Shift + P などで Remote-SSH でリモートに接続します.

画面左下のマークでリモートに接続しているのを確認します.

Screenshot from 2023-01-08 21-14-55.png

あとは .ipynb 形式のファイルを作り, 画面右下で Jupyter や Python 環境(Conda 環境)がリモートのを選べるのでよろしくやるだけです!

Screenshot from 2023-01-08 21-15-00.png

Screenshot from 2023-01-08 21-25-35.png

ローカルで Python lsp 入れていると, コード補完などもよろしくやってくれるようです :eye:

問題?: vim の settings.json が反映されない

esc 対応で

VSCodeでのjupyterとvimの共用
https://qiita.com/SoseSose/items/b1db862cffbc0c6afdf6

の設定をリモート側の settings.json に記載しても,

Screenshot from 2023-01-11 18-04-59.png

とグレーアウトされ

This setting has an application scope and can be set only in the user settings file

というよくわからない warning が出て反映されません.
vim 拡張は global 反映なので, ローカルの settings.json に記載する必要があるようです.

また, keybindingds.json 指定もあるようですが, こちらはどうもいろいろいじらないとダメな感じでした

ただ, settings.json 設定しても, コマンドモードで esc すると cell からフォーカスははずれてイマイチつかいづらいです.

TODO

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?