Execute a Simple Jupyter Notebook
How to use the start_analytics command to allocate resources and execute a Jupyter Notebook.
This procedure provides instructions for executing Jupyter Notebooks on the system.
- Log on to a login node.CS_Storm_Hostname is used as an example for the login node name in the following example:
$ ssh CS_Storm_Hostname
- Load the
analyticsmodule$ module load analytics
- Obtain a job allocation.Example for Slurm:
$ salloc -N numberofNodes
Example for PBS Pro:$ qsub -I -lnodes=numberofNodes
$ qsub -I -lnodes=numberofNodes $ module load analytics $ module load openmpi/gcc/64/3.0.0
The path shown in the preceding example for loading the openMPI module depends on the system.
- Load the
analyticsmodule$ module load analytics
- Create an SSH tunnel from the localhost to the login node in a new terminal window.
$ ssh -N -f -L localPort:localhost:loginPort hostname
$ ssh -N -f -L localPort:localhost:loginPort hostname
Here, localPort is used to view the UI from the local machine and the loginPort is used in the ssh tunnel. These port values should match the localPort and loginPort values in the steps below. start-analytics runs on the hostname login node. - Execute the start_analytics command, specifying the login and UI ports. Running with the --login-port and --ui-port options automatically sets the
JUPYTER_RUNTIME_DIRenvironment variable. If this variable is not set to a writeable directory, Jupyter will not run.$ start_analytics --login-port loginPort --ui-port UIPort
Example for Slurm:$ start_analytics --ssh-tunnel loginPort:UIPort
Example for PBS Pro:$ start_analytics --ssh-tunnel loginPort:UIPort --tunnel-host CS_Storm_Hostname
Here:- loginPort is the port to use on the login node.
- UIPort is the port that the UI runs on.
For Slurm, allocating resources and starting the analytics cluster can be performed simultaneously, as shown in the following example:$ salloc -N 4 start_analytics --login-port loginPort --ui-port UIPort
- Start the Jupyter Notebook application. To use Jupyter with a Conda environment, install Jupyter in the Conda environment and activate the environment before running the jupyter notebook command.The following example assumes that Jupyter Notebook is not being used with a Conda environment.
$ jupyter notebook --port UIPort [I 20:23:57.376 NotebookApp] Serving notebooks from local directory: /home/users/username [I 20:23:57.376 NotebookApp] 0 active kernels [I 20:23:57.376 NotebookApp] The Jupyter Notebook is running at: http://localhost:9100/?token=6aacf7f9e13c412921a4fde10ae51d638065f60839114193 [I 20:23:57.376 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [W 20:23:57.380 NotebookApp] No web browser found: could not locate runnable browser. [C 20:23:57.381 NotebookApp] Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:9100/?token=6aacf7f9e13c412921a4fde10ae51d638065f60839114193 - Start the Jupyter Notebook application. The following example assumes that Jupyter Notebook is not being used with a Conda environment.
$ jupyter notebook --port UIPort --notebook-dir=./ --no-browser [I 20:23:57.376 NotebookApp] Serving notebooks from local directory: /home/users/username [I 20:23:57.376 NotebookApp] 0 active kernels [I 20:23:57.376 NotebookApp] The Jupyter Notebook is running at: http://localhost:9100/?token=6aacf7f9e13c412921a4fde10ae51d638065f60839114193 [I 20:23:57.376 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [W 20:23:57.380 NotebookApp] No web browser found: could not locate runnable browser. [C 20:23:57.381 NotebookApp] Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:9100/?token=6aacf7f9e13c412921a4fde10ae51d638065f60839114193 - Copy and paste this URL into a browser when connecting for the first time.To login with a token, point a browser at
http://localhost:localPort/?. Enter the received token when prompted.Alternatively, set the password in the Jupyter Notebook server.
- Shut down the Jupyter Notebook server by killing the Jupyter process on the interactive node.