37

i'm working with VSCode on remote server via ssh with the jupyter notebook extension. but when im disconnect from the session the process of the code is stopped. is there a way to run the notebook from the VSCode with a backgroung process with tools like tmux. cause i'm far of being a linux expert and i cant figure out how can i run the notebook process with tmux via the VSCode.

thanks a lot in advance.

idanso
  • 373
  • 3
  • 6
  • 1
    did you find a way to do this? – Karl Sep 02 '22 at 00:26
  • still no sorry, if someone found a solution it will be great – idanso Nov 16 '22 at 14:04
  • It's insane that 27 people upvoted your question and there's nobody answering. What do others do instead? I have my code and data in a remote server that I connect using vscode via ssh. I have a long running task that I want it not to be cancelled when disconnecting. What's my alternative? – Ali Tou Nov 19 '22 at 15:27

2 Answers2

1

Simply start a tmux process in the remote terminal start Jupyter in the tmux session. You can go out of the tmux session without closing it. In VSC you can choose the tmux session as the host.

Malte
  • 11
  • 2
  • 3
    I've used `tmux` for running stuff from the command line, but never with VSCode. Can you elaborate a little on the VSCode part? Mostly I'm not sure how to "choose the tmux session as the host" in VSCode. I tried choosing ``, but I'm pretty sure that's not right... – jbm Nov 22 '22 at 22:30
  • This works, but there is a catch. If there is a cell running when you close VS Code, its process will be interrupted. So, it is not that useful if you have a cell that runs for a long time, apparently. – pietro_molina Nov 23 '22 at 17:04
0
  1. Open a new tmux session on your server: e.g., tmux new -s my_sess
  2. Go in the folder with your notebook
  3. If you use Anaconda, activate the environment with your libraries (including Jupyter)
  4. Start the jupyter notebook, optionally specifying the port where you want to forward it: e.g., jupyter notebook --no-browser --port=8080 &
  5. Disconnect from tmux
  6. Open your notebook in VS Code
  7. On the top-right, click the button to select your kernel and choose the option "select another kernel" -> "Existing jupyter server" -> "Enter the URL of the running Jupyter server"
  8. If you did as I wrote in point 4, write "http://localhost:8080/"
  9. At this point, you are asked to choose a Python kernel. I think you can choose whatever and it will use in any case the kernel running on the jupyter server in tmux
filloz
  • 1