🦣

How to maintain the jupyter notebook while background

2024/07/05に公開

For Kaggle users using PC from remote with SSH.

1 Awake the server(localhost)

nohup jupyter notebook --allow-root > output.log 2>&1 &

copy the URL like http://localhost:8890/?token=be27f057c61ef5a258fc9f1cc989905b9085450e34305f44 in output(in nohup.out file).

2 Set the kernel

Open the Jupyter file in VSCode, click on Select Kernel in the top right corner, select another kernel → Existing Jupyter Server → Paste the link you copied.

It's done, this will keep it running even if you close the vscode.

3. Finish the server

List the server

jupyter notebook list

Stop.

jupyter notebook stop 8890

8890 is your port number.

3.1 Additonal

・Note:
According to the GitHub issue, the above steps must be done for each notebook.

Is this tedious to do for every individual notebook one wishes to persist? Yes, absolutely. Is it less tedious than having to rerun remote notebooks anytime your computer snoozes/sleeps? ¯(ツ)/¯

・When you wanna use a command from the terminal?:

nohup your_command > output.log 2>&1 &

4. Reference

[1] SSH接続+VSCodeでのJupyterカーネルのバックグラウンド実行 for Kaggler

Discussion