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

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

Related

In PyCharm the Jupyter Server tool window to preview server's configuration details gives nothing

I use PyCharm Professional and I am trying to launch Jupyter Notebook inside PyCharm IDE.
I followed the official instructions Manage Jupyter notebook servers.
I installed Jupyter and configured python 3.8 interpreter using virtual environment. I do not use conda.
When I run the first cell "Starting Jupyter Server" message is shown on the Jupyter top bar. I now that I have to insert Jupyter password or activation token for the server.
When I run command inside PyCharm terminal it gives me only the address:
jupyter notebook list
Currently running servers:
http://localhost:8888/
As officials say here must be shown authentication token for the server, but it is missing.
So, where I can find this token to enter the Jupyter Server and see other server's configuration details?
I have just found the answer by myself.
I have Jupyter configuration already in the folder ~/.jupyter/jupyter_notebook_config.py where the password and other parameters are set. So, to enter the server all I had to do is to enter the password which I set on my own in the above configuration file in the past.

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.

VSCode remote Jupyter Notebook - Access the remote jupyter shell in VSCode terminal

I can connect to a remote Jupyter Notebook server with a token from VSCode through the "Python: Specify Jupyter server URI" command from the Command Palette.
However, I couldn't find a way to do this:
Access the remote server's terminal to run command-line Python code. Using the ! magic in cells itself is not useful as the command line code is interactive.
Is there a way to do this?
A little late and not sure if it's the answer you were looking for, but I personally prefer to access remote server's terminal from Windows Terminal, you can set a profile for your server as shown here SSH in Windows Terminal
You can mix this with the extension Windows Terminal Integration for vscode

Specify hostname to jupyter notebook when running on remote server

I'm running a notebook on a remote server, to which I connect from my local machine via browser. One slight annoyance I have is it prints this on start:
Serving notebooks from local directory: /home/xxxxxxx
0 active kernels
The Jupyter Notebook is running at:
http://(friendly or 127.0.0.1):8888/
Where friendly is the friendly name of the host. The FQDN of the host is actually friendly.x.y.z.com. I would like it to print this:
The Jupyter Notebook is running at:
http://friendly.x.y.z.com:8888/
so that the URL is directly clickable from the console. Is there a config option I can pass somewhere to do that in jupyter notebook to explicitly specify the hostname I want displayed?
To be clear, http://friendly.x.y.z.com:8888/ resolves correctly in the browser despite the above message.
You should first generate the config file:
jupyter notebook --generate-config
Then using the config file you can set the custom URL by editing the config file ~/.jupyter/jupyter_notebook_config.py changing the following line:
c.NotebookApp.custom_display_url = 'http://friendly.x.y.z.com:8888'
So when you start the server it will show this URL concatenated with the token.

How do I set up Jupyter notebook on a linux server (RHEL7) for my team to use via Chrome browser?

I am leading a team of analysts and want to introduce them to Jupyter Notebook as a window into Python programming.
We have Anaconda downloaded and installed on our Linux server. I've asked our IT to help set it up to run on Google Chrome and they have been able to only provide the following steps:
source /R_Data/anaconda3/etc/profile.d/conda.sh
this kicks off Anaconda on the server, must run in PUTTY. We stored the installation in the same location as RStudio hence the R_Data in the filepath.
/R_Data/anaconda3/bin/jupyter-notebook --ip 0.0.0.0 --port 8889
This sets up the port 8889 with a token generated each time from scratch. We then need to grab the token id and paste into Chrome with the full URL per step 3
http://localhost:8889/?token=ea97e502a7f45d....
When I paste this in Chrome it loads Jupyter.
While this gets the job done it seems less than ideal for an entire team of analysts to have to do this each time. We also have RStudio installed on the same server but that simply opens from Chrome using a URL since I assume it is always running in the background. Jupyter and Anaconda seem to only run once they are kicked off first in PUTTY and I would like a way to bypass those steps.
I am familiar with the Jupyter config file however my limited understanding as a non-developer tells me it applies only to each user and cannot be applied to all users simultaneously (i.e. as a root user on the server or something to that effect).
I am hoping someone here might point me in the right direction. I should also point out that as a Redhat user I can't follow instructions based in Ubuntu since that syntax seems different.
Many thanks for the help.
Yoni
A convenient way is to run jupyter notebook --no-browser --port=12345 on your server while connecting through the ssh tunel as ssh -N -f -L 12345:localhost:12345 myserveralias. Now jupyter is on your 12345 localhost. Things like AutoSSH or Keep Alive will help with an erratic network, however, take security into account.

Categories

Resources