The Jupyter notebook extends the console-based approach to interactive computing in a qualitatively new direction, providing a web-based application suitable for capturing the whole computation process: developing, documenting, and executing code, as well as communicating the results. The Jupyter notebook combines two components:
A web application: a browser-based tool for interactive authoring of documents which combine explanatory text, mathematics, computations and their rich media output.
Notebook documents: a representation of all content visible in the web application, including inputs and outputs of the computations, explanatory text, mathematics, images, and rich media representations of objects.
- Software URL: https://jupyter.org
- Documentation: https://jupyter-notebook.readthedocs.io/en/stable/
Creating a Jupyter env
In this example, we will create an environment by Miniconda including Jupyter notebook and then run a Jupyter server in the cluster (Lewis) and connect to the server from a local computer.
First review Anaconda page to learn more about Conda and set up the recommended configuration
Use the following to create a Jupyter environment:
srun -p Interactive --qos interactive --pty /bin/bash module load miniconda3 conda create --prefix ./jupyter_env jupyterlab # it will create an env called "jupyter_env" in your current directory
jupyter_env is created, we can use the following to activate the environment:
source activate ./jupyter_env
Running Jupyter server
To run a Jupyter notebook server use:
jupyter-notebook --no-browser --ip 0.0.0.0
The above command generates some outputs including the host name, port number and the URL, as follows:
To open the Jupyter notebook in a browser, first open a new terminal in your local computer and use the following command for a local port forwarding to connect to the given host and port of the Jupyter server:
ssh -NfL PORT:HOST:PORT USER@lewis.rnet.missouri.edu
Note that you should update HOST and PORT based on the Jupyter server host name and port number, and USER by your Lewis user ID. For example based on the information in the above screenshot PORT:HOST:PORT is
8888:lewis4-cBk-hpc2-node279:8888. PORT:HOST:PORT is always subject to change and needs to be updated each time.
Now, you can open a browser in your local computer and paste the URL (see the above screenshot) in the address bar to connect the Jupyter server.
To terminate your connection, use
Ctrl-C in the cluster terminal to shut down the server and close the local terminal.