How to reconnect to an existing Jupyter notebook session in VS code? - python

I remember I was able to reconnect to an existing Jupyter notebook session in VS code before by changing the kernel for a notebook. Now the option to reconnect to an existing session is gone, see:
How do I reconnect to an existing Jupyter notebook session in VS code?
To be clear, the sessions were never shut down. In fact, I can still see them running in the Running tab of my browser version of jupyter notebook, although clicking on them results in a 404 error:
The jupyter kernel is running on a remote server. I use a SSH session to connect back to it when I work.
Current versions: VS code is v1.68.1 and the Jupyter extension on remote machine is v2022.5.1001601848, if that helps.

If you would like to connect to an existing jupyter server can you do so by going into the command Jupyter: Specify Jupyter Server for Connections and selecting the appropriate remote server from the list. If the required server is not on that list, then you can select it.

Related

How to maintain .ipynb running in the background with VSCode?

I have installed jupyter-related plugins in VS Code. While I close the VS Code, the GPU memory is cleared. I can't use jupyter like the traditional method in the browser.
I changed the jupyter to remote with localhost: port in VS Code, the Jupyter: Server Remote displayed in the button of VS Code GUI.
Steps:
The remote jupyter notebook is running in the tmux with & bash option.
Add port forward in VSCode.(maybe unnecessary)
Ctrl + Shift + P and search "Jupyter: Specify Jupyter Server for connections".
Add URL with the token.
Run a ipynb file and nvidia-smi to see the usage of GPU.
Close the VSCode, the GPU memory is clear.
When you use remote mode, the code runs in the server instead of the local computer.
Please operate again according to the documentation.
Select the Jupyter Server: local button in the global Status bar or run the Jupyter: Specify local or remote Jupyter server for connections command from the Command Palette (Ctrl+Shift+P).
When prompted to Pick how to connect to Jupyter, select Existing: Specify the URI of an existing server.
When prompted to Enter the URI of a Jupyter server, provide the server's URI (hostname) with the authentication token included with a URL parameter. (If you start the server in the VS Code terminal with an authentication token enabled, the URL with the token typically appears in the terminal output from where you can copy it.) Alternatively, you can specify a username and password after providing the URI

How to use JupyterLab in Visual Studio Code

is there a way to use JupyterLab in VS Code? I know that VS Code provides the Jupyter Notebook extension. However, I need to connect to another server remotely......
Any guidance will be appreciated!
You can offload intensive computation in a Jupyter Notebook to other computers by connecting to a remote Jupyter server. Once connected, code cells run on the remote server rather than the local computer.
To connect to a remote Jupyter server:
Select the Jupyter Server: local button in the global Status bar or
run the Jupyter: Specify local or remote Jupyter server for
connections command from the Command Palette (Ctrl+Shift+P).
When prompted to Pick how to connect to Jupyter, select Existing:
Specify the URI of an existing server.
When prompted to Enter the URI of a Jupyter server, provide the
server's URI (hostname) with the authentication token included with
a URL parameter. (If you start the server in the VS Code terminal
with an authentication token enabled, the URL with the token
typically appears in the terminal output from where you can copy
it.) Alternatively, you can specify a username and password after
providing the URI.
For guidance about securing a notebook server, refer to the Jupyter documentation.

Error when open Jupyter Notebook from putty

I'am trying to open Jupyter Notebook from Putty. I have a server where is installed Python and Jupyter. I followed all the steps from this post Remote access Jupyter notebook from Windows but it doesn't work. I got the error: This site can't be reached.
Any idea?
Thx
edit: I added a photo with the ps from putty and the error from browser. It's said:
This site can't be reached
.
The good old logout/reboot mechanisms work in this case too!
You can try closing the jupyter connection in the tunnel's connection, logout from the remote server, re-connect and try. Has worked a few times for me today.
If that doesn't work, there might be stale jupyter notebook processes on the remote server. Query for them and kill them and then logout-log back in and try.
If that still does not work, try implementing your code through ipython to check if Jupyter is working at all, even if its user interface isn't loading on your browser.

Re-connecting to remotely run kernel with jupyter lab

I am working on a remote server with jupyter lab and has one job running. However, the connection was dropped and now I'm trying to re-connect to the same running kernel. I honestly read through many examples and jupyter docs, but I couldn't find a solution. My previous run was outputting intermediate results and I am wondering whether I can re-connect back to the running kernel and continue see the output?
I normally connect via ssh:
ssh -L 8000:localhost:8080 usere#123.45.678.9
...
then I run
jupyter notebook --no-browser --port=8080
and in the browser on my local machine I simply open 'locahost:8000' and it works nicely.
I tried to repeat those steps but I can't re-connect to existing running kernel and continue see the output.
Any suggestions please?
Suddenly, I understand your problem. So you are not let server keep running. Instead, you manually launch it everytime.
Basically the idea is that you need to make it keep running. Somehow like nohup jupyter notebook --no-browser --port=8080 & or use systemd. So that when you lose connection, the jupyter server is still running.
Then you can just reconnect to server by ssh -L 8000:localhost:8080 usere#123.45.678.9. And open locahost:8000. Finally you will see that everything is just the same as you left.

How to use iPython notebook with ngrok

(Maybe better ask on superuser?)
iPython works fine if I use an ssh tunnel.
Using ngrok
iPython notebook loads I get an error about mathjax not loading.
I can enter code into cells but if I try to execute I get no result but the kernel seems to be running. Basically nothing works. I have no idea if I am doing something wrong or if this just wont work.
I am starting starting ngrok like this
./ngrok -authtoken myauthtoken 5023
and ipython notebook like
ipython notebook --no-browser --port=5023
Then connect to the iPython session at
https://mysubdomain.ngrok.com
Author of ngrok here: ipython notebooks and any other websocket connections now work properly as of ngrok 0.22 which is available at https://ngrok.com/download

Categories

Resources