Difference between revisions of "Running Jupyter Notebook"

(Imported from Wikispaces)
 
Line 74: Line 74:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
The first port number is the one you connect to on your local computer, and can remain unchanged.
 
The first port number is the one you connect to on your local computer, and can remain unchanged.
[[Category:python]][[Category:ipython]][[Category:ipython notebook]]
+
 
 +
[[Category:Python]]

Revision as of 22:47, 4 December 2019

On VDI

Currently, the easiest way to run IPython Notebook is on NCI's | Virtual Desktop Infrastructure (VDI). For a guide to set up and use VDI, click | here.

Within VDI, open a Linux terminal (Applications menu -> System Tools -> Terminal). Inside the Terminal, load the conda environment

module use /g/data3/hh5/public/modules
module load conda

You should then be able to start the notebook with

jupyter notebook


On Raijin

If you don't have access to VDI, you can still run IPython Notebook from Raijin in a browser on your local computer. Currently these instructions show how to run the notebook from the login node - which is not recommended - and, as such, are just a demonstration of what is possible. Ideally the notebook should be run from an interactive session. Log in to raijin using SSH, forwarding your ports as you go (you might have to sudo this)

ssh -L 8889:localhost:8889 [USERNAME]@raijin.nci.org.au

Load the conda environment

module use /g/data3/hh5/public/modules
module load conda

Set up an ipython profile that serves your notebooks (adapted from [[1]])

ipython profile create nbserver

Then modify the Notebook config file in ~/.ipython/profile_nbserver/ipython_config.py (or create that file if it wasn't generated) so that it reads:

c = get_config()
c.NotebookApp.open_browser = False
# It is a good idea to put it on a known, fixed port - must match port used to ssh in.
c.NotebookApp.port = 8889
c.NotebookApp.base_project_url = 'ipython'

# The following can be used to set up a password,
# from here: https://ipython.org/ipython-doc/dev/notebook/public_server.html
# c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
# c.NotebookApp.ip = '*'
# c.NotebookApp.password = u'sha1:bcd259ccf...[your hashed password here]'

The dependencies required for ipython have been installed and should load automatically when the ipython module is loaded.

You should be able to start the notebook with

ipython notebook --profile=nbserver

On your local computer, direct your browser to [[2]] and you should have access to the notebook.

If another user is already running an ipython session using the port number above, the ipython process will tell you with a message like this:

[I 11:06:03.545 NotebookApp] The port 8899 is already in use, trying another random port.

and it will tell you which port it has chosen instead:

[I 11:06:03.552 NotebookApp] The IPython Notebook is running at: http://localhost:8900/ipython/

Unfortunately the ssh connection will only forward the port you specified when you logged in. You should edit the ~/.ipython/profile_nbserver/ipython_config.py file, change the port number to the one ipython chose (or another higher number less than 65535), log out and log back in, using the new port number.

ssh -L 8889:localhost:8890 [USERNAME]@raijin.nci.org.au

The first port number is the one you connect to on your local computer, and can remain unchanged.