1. Home
  2. Docs
  3. Tips and Tricks
  4. Using Jupyter Notebooks in GCE

Using Jupyter Notebooks in GCE

To begin, login to one of the compute nodes via ssh.  We’ll use compute-01 for this example. If you use compute-02, change the commands below accordingly.  Also, substitute <yourargonneusername> with your actual Argonne username you use to login on GCE.

ssh -J <yourargonneusername>@logins.cels.anl.gov <yourargonneusername>@compute-01.cels.anl.gov

You’ll want to make sure you’re using the python module rather than the system version in case you want to load any python modules.

module load anaconda3

Launch Jupyter Notebook on the node:

jupyter notebook --no-browser &

You should see something like:

[I 13:10:42.917 NotebookApp] Writing notebook server cookie secret to /run/user/20001/jupyter/notebook_cookie_secret
/nfs/gce/software/custom/linux-ubuntu18.04-x86_64/anaconda3/rolling/lib/python3.7/site-packages/IPython/paths.py:53: UserWarning: Moving ~/.config/ipython to ~/.ipython
warn('Moving {0} to {1}'.format(cu(xdg_ipdir), cu(ipdir)))
[I 13:10:48.611 NotebookApp] JupyterLab extension loaded from /nfs/gce/software/custom/linux-ubuntu18.04-x86_64/anaconda3/rolling/lib/python3.7/site-packages/jupyterlab
[I 13:10:48.612 NotebookApp] JupyterLab application directory is /nfs/gce/software/custom/linux-ubuntu18.04-x86_64/anaconda3/rolling/share/jupyter/lab
[I 13:10:48.614 NotebookApp] Serving notebooks from local directory: /home/<yourusername>
[I 13:10:48.614 NotebookApp] The Jupyter Notebook is running at:
[I 13:10:48.615 NotebookApp] http://localhost:8888/?token=b1655f93f919bfa5a6834d38997e3e5410c5ab83df02598b
[I 13:10:48.615 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:10:48.623 NotebookApp]

To access the notebook, open this file in a browser:
file:///run/user/20001/jupyter/nbserver-22461-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=b1655f93f919bfa5a6834d38997e3e5410c5ab83df02598b

Please make a note of the provided URL. You will need that later. Also, please note that the port number after localhost may be different. In this example, it is 8888. You should change the below command to match this port where necessary (as well as with the proper compute node number).

From another terminal on your local machine, run:

ssh -J <yourargonneusername>@logins.cels.anl.gov -L 8888:localhost:8888 <yourargonneusername>@compute-01.cels.anl.gov

This will open a new, port forwarded session on the appropriate compute node. You may encounter a scenario where the default port of 8888 is already in use and see something like:

bind [127.0.0.1]:8888: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 8888
Could not request local forwarding.

If this happens, you may want to change the port altogether. You can change it by adding the following to your Jupyter Notebook command from earlier. Simply cancel the process and restart the process with:

# jupyter notebook --port=<port number> --no-browser &

We recommend you simply increase the port number by one to the next value from the default. For example, 8889 or 8890 if others are in use.

Finally, cut-paste the URL obtained by launching Jupyter Notebook on the compute node earlier into a browser (Firefox/Chrome) running on your local machine.

This should launch the Jupyter Notebook on the browser of your local machine.

Was this article helpful to you? Yes No

How can we help?