skip to Main Content

I have a remote Jupyter server on the port 9292 on the ip 192.168.10.92.
I can tunnel this port no my http://localhost:9292/ through ssh:

ssh -L localhost:9292:localhost:9292 [email protected]

This enable me to connect to the remote Jupyter server using my local browser:

remote Jupyter on my local browser

This also enable me to create, save, write and obviously run notebooks from the remote Jupyter server.

Now what I want is to be able to do the same things on my local Visual Studio Code. With this purpose I opened Visual Studio and run from the Command Palette (Ctrl+Shift+P) Jupyter: Specify local or remote Jupyter server for connections and I specified as URI http://localhost:9292. This made me able to create new notebooks from my local Visual Studio and to run them on the remote server, exploiting its kernel and its resources (RAM, CPUs, GPU). The problem is that I have not found a way to read, save and create notebooks on the remote Jupyter server; if I try to save the notebook I have just create on visual studio, the "Save As" option just let me save it on my local workspace.

TO RESUME:

I just want to know if there is a way to have on my visual studio a sort of "navigator" that let me read and execute notebooks on the remote server with the remote Jupiter kernel.

PS:

Both server and local machine are Linux machines.

Any help will be appreciated.

2

Answers


  1. Not sure whether this is the most elegant solution, but you can do that with VSCode extension: Remote – SSH.

    Once you have that installed. To connect to your server and files open Command Palette via Ctrl + Shift + P and run Remote-SSH: Connect to Host... command.

    It will open new window of VSCode connected to the server, and you should see your files through Explorer on the side panel.

    Login or Signup to reply.
  2. this is possible and requires the following steps:

    Installation of Code-server

    To connect to the server using VS Code, Code-server must be installed on the DSWS for the user according to this guide. Write your own username instead of [username].

    curl -fsSL https://code-server.dev/install.sh | sh
    sudo systemctl start code-server@[username]
    sudo systemctl enable --now code-server@[username]
    

    Setup VS Code

    Make sure your VS Code is up-to-date.
    Open a new window in your local VS Code and install the following Extensions:

    Python
    Jupyter
    Remote — SSH
    

    Connect the VS Code to the Host

    Click on the >< — Symbol (“Open a Remote Window”) in the bottom left and select in the top bar “Connect Current Window to host”.
    Connect to the remote machine via SSH, using your username and IP address. Note messages popping up in VS Code’s UI, you have to enter the remote OS, a keyfile, or your password.

    Now open a respective directory in which you want to develop. Therefore, open the Explorer, “Open Folder” and specify a directory on the remote machine. Then confirm with your password and that you are trusting the code.

    Connect to the Kernel

    Connect to a remote Kernel in Docker
    Create a new Juypter Notebook or create a new one. Then run a cell using [Shift]+[Enter] and note a message in the top bar approaches. Select “Existing Jupyter Server” and “Enter the URL of the running Jupyter Server”.

    Then you have to specify the remote kernel you want to connect with. Therefore provide the URL as you would open it in a browser, containing the hostname (or IP-address), the exposed port, and the token of the Jupyter server. The token can be extracted in a VS Code Terminal (as we are already connected per SSH) or in an additional Terminal on the remote machine. Use the command jupyter server list or if it runs in docker docker exec -it [ service_name | UID] jupyter server list to extract the token.

    Finally, select “Python 3” or whatever kernel you want and start computing. Of course, the same works for standard Python files.

    Now you should run all Jupyter Notebooks and Python Files!

    Disclaimer: Note that this instruction is from this tutorial on Connect your remote GPU-Jupyter to your local VS Code — A great Deep Learning Solution which additionally provides screenshots.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search