I would like to have multiple instances of ipython notebook running on different ports for the same user. Is it possible?
Something like a list of ports for 'NotebookApp.port' with a default one.
run jupyter notebook --port=8090
change 8090 for the port you want
Just run jupyter notebook a second time; it will automatically select another port to use.
Related
I am doing some analyses using vscode on a remote server that has got SLURM installed to manage jobs and provide parallel computing. I would like to run each cell in the Jupyter notebook as an interactive job on SLURM the same way my command line code would be run as an interactive SLURM job after I have used srun to request compute nodes. The jobs I need to run on the Jupyter notebook require a lot of memory, so I need to run them using SLURM.
My current work around is to run srun on the terminal and start a python terminal, then I copy and paste the code from each cell of my notebook into the python terminal. I'd really appreciate your help.
It is an old question, but answering as I also came across this problem recentrly.
After you do srun on a terminal, you should be able to ssh directly into your compute node in VScode and use all the capabilities of the compute node in the interactive mode/notebook
The steps I take, for example, are:
in a terminal (e.g. powershell), srun into a node
add that node to your config file, so that you can ssh into it
open vscode and ssh into that node
run code in interactive window/notebook, with access to CPU/GPU of the node
Problem
I am trying to connect to my school's computing cluster (aka a linux server with "login node" and "computing node") using VS Code's Remote SSH, but I cannot figure out how to run a command after SSH-ing.
Goal
I simply want to view Python code and test some small lines in a .ipynb jupyter notebook in the computing platform's environment.
Description
Basically, normally in the command line (or mobaXterm of a Windows machine) of my local machine, I first log onto the computing platform's login node with ssh -Y -L PORT:127.0.0.1:PORT username#computing.cluster.ip, and then run srun -t 0-12:00 --pty -p gpu --gres=gpu:1 --x11 --tunnel PORT:PORT /bin/bash to log onto the computing node interactively (shown command allows for port forwarding). The problem is, in VS Code I can only connect to the login node, but after that there's no way for me to run another command and log onto the computing node. The reason I need to get to computing node is that I want to test something with a .ipynb file interactively on VS Code while reading the code, and the login node does not allow me to perform computation.
Failed trials
I've been trying Code-Server, but it does not support .ipynb well (it keeps asking me to install jupyter notebook even though I have installed it in my conda env), possibly because it by default recognizes HPC cluster's Python interpreter which I cannot modify (I can't even select Jupyter kernel in code-server). I also tried to directly use Jupyter Notebook (open Jupyter with port forwarding after getting onto computing node), but reading code on it is much more inconvenient.
Would greatly appreciate your suggestions!
I am using a windows machine and I have several running sessions of the jupyter notebook. Each session display the content in different ports. I would like to know if there is a way of getting a report including the different sessions I am running and the different ports on which they are displaying the content. I could not find that in the documentation.
Usually what you can do is pass the --help flag to the jupyter notebook command and read the informations in particular here
$ jupyter notebook --help
The Jupyter HTML Notebook.
This launches a Tornado based HTML Notebook Server that serves up an
HTML5/Javascript Notebook client.
Subcommands
-----------
Subcommands are launched as `jupyter-notebook cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter-notebook cmd -h`.
list
List currently running notebook servers.
stop
Stop currently running notebook server for a given port
password
Set a password for the notebook server.
Options
-------
...
Oh ! A list sub command. let's try it:
$ jupyter notebook list
Currently running servers:
http://localhost:8888/ :: /Users/myuser/dev/ipython-website
http://localhost:8889/ :: /Users/myuser
.. well that's on macOS, but you should get the same on Windows.
One of the questions is why do you have multiple sessions as the notebok can browse the filesystem. It is likely confusing.
Enjoy.
i have two machines connected via lan.
other system's ip address is 192.1xx.x.x
i want to run jupyter ipython query's on my machine which can be exexuted on his machine.
at the start of ipython notebook, there is a black screen which contains this:
[I 11:12:52.802 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
can i change this to my specified location?
You can specify the port you want Jupyter to run uncommenting/editing the following line in ~/.jupyter/jupyter_notebook_config.py:
#c.NotebookApp.port = 8888
In case you don't have a jupyter_notebook_config.py try running jupyter notebook --generate-config. See this for further details on Jupyter configuration.
In case you are accessing Jupyter at a remote machine you can also try just leaving Jupyter running at its default port and make an SSH tunnel to your local machine at the port you want, e.g.:
ssh -fNL <new port>:localhost:8888 <your ssh config>
Run the Anaconda Prompt, generate the config file, if you don't have it and edit the config file and change c.NotebookApp.ip with your IP Adress '192.1xx.x.x'
On Anaconda Prompt:
If the file not exist, generate a config file:
jupyter notebook --generate-config
Output:
(base) C:\Users\youruser>jupyter notebook --generate-config
Writing default config to: C:\Users\youruser\.jupyter\jupyter_notebook_config.py
(base) C:\Users\youruser>
Change to jupyter directory:
cd .jupyter
Modify the config file from:
## The IP address the notebook server will listen on.
#c.NotebookApp.ip = 'localhost'
To:
## The IP address the notebook server will listen on.
c.NotebookApp.ip = '192.1xx.x.x'
First you need to generate a configuration file by typing:
$> jupyter notebook --generate-config
Writing default config to: /{home-directory}/.jupyter/jupyter_notebook_config.py
Next you need to edit that configuration to change the port number:
vi /{home-directory}/.jupyter/jupyter_notebook_config.py
Look for the following line (which is commented out by default) and comment in the line and change the port number:
(default configuration)
## The port the notebook server will listen on.
# c.NotebookApp.port = 8888
(comment removed, port changed)
## The port the notebook server will listen on.
c.NotebookApp.port = 9999
On a Mac, I had to use my machine's name instead of localhost.
To get this, open a terminal and run:
hostname
So in the browser, instead of localhost:8888/... I entered mac-mini.home:8888/... (where ... represents the rest of the url).
I'd like to find out where in the Jupyter config this can be overridden, because it is not intuitive, IMO.
I am taking my first steps with ipython notebook and I installed it successfully on a remote server of mine (over SSH) and I started it using the following command:
ipython notebook --ip='*' ---pylab=inline --port=7777
I then checked on http://myserver.sth:7777/ and the notebook was running just fine. I then wanted to close the SSH connection with the server and keep ipython running in the background. When I did this, I couldn't connect to myserver.sth:7777 anymore. Once I connected again to the remote server by SSH, I could connect again to the notebook. I then tried to use screen to start ipython: I created a new screen by screen -S ipy, I started ipython notebook as above and I used Ctrl+A,D to detach the screen and exit to the TTY. I could still connect remotely to the notebook. I then closed the SSH connection and I got a 404 NOT FOUND error when I tried to access my previously stored notebook and I couldn't see it on the list of notebook at http://myserver.sth:7777/. I tried to create a new notebook, but I got a 500 Internal Server Error.
I also tried running ipython notebook with and without using sudo.
Any ideas?
Rather than use screen, perhaps you could switch to an init script or supervisord to keep IPython notebook up and running.
Let's assume you go the supervisord route:
Install supervisord
Install supervisord using your package manager. For ubuntu it's named supervisor.
apt-get install supervisor
If you decide to install supervisor through pip, you'll have to set up its init.d script yourself.
Write a supervisor configuration file for IPython
The configuration file tells supervisor what to run and how.
After you install supervisor, it should have created /etc/supervisor/supervisord.conf. These lines should exist in the file:
[include]
files = /etc/supervisor/conf.d/*.conf
If they contain these lines, you're in good shape. I only show them to demonstrate where it expects new configuration files. Your configuration file can go there, named something like /etc/supervisor/conf.d/ipynb.conf.
Here's a sample configuration that was generated by Chef by an ipython-notebook-cookbook that runs the notebook in a virtualenv:
[program:ipynb]
command=/home/ipynb/.ipyvirt/bin/ipython notebook --profile=cooked
process_name=%(program_name)s
numprocs=1
numprocs_start=0
autostart=true
autorestart=true
startsecs=1
startretries=3
exitcodes=0,2
stopsignal=QUIT
stopwaitsecs=10
user=ipynb
redirect_stderr=false
stdout_logfile=AUTO
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
stdout_capture_maxbytes=0
stdout_events_enabled=false
stderr_logfile=AUTO
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=10
stderr_capture_maxbytes=0
stderr_events_enabled=false
environment=HOME="/home/ipynb",SHELL="/bin/bash",USER="ipynb",PATH="/home/ipynb/.ipyvirt/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games",VIRTUAL_ENV="/home/ipynb/.ipyvirt"
directory=/home/ipynb
serverurl=AUTO
The above supervisor config also relies on an IPython notebook configuration (located at /home/ipynb/.ipython/profile_cooked/ipython_notebook_config.py). This makes configuration much easier (as you can also set up your password hash and many other configurables).:
c = get_config()
# Kernel config
# Make matplotlib plots inline
c.IPKernelApp.pylab = 'inline'
# The IP address the notebook server will listen on.
# If set to '*', will listen on all interfaces.
# c.NotebookApp.ip= '127.0.0.1'
c.NotebookApp.ip='*'
# Port to host on (e.g. 8888, the default)
c.NotebookApp.port = 8888 # If you want it on 80, I recommend iptables rules
# Open browser (probably want False)
c.NotebookApp.open_browser = False
Re-read and update, now that you have the configuration file
supervisorctl reread
supervisorctl update
Reality
In reality, I used to use a Chef cookbook to do the entire installation and configuration. However, using configuration management with tiny stuff like this is a bit of overkill (unless you're orchestrating these in automation).
Nowadays I use Docker images for IPython notebook, orchestrating via JupyterHub or tmpnb.