Difference between revisions of "Running Jupyter Notebook"

(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=On VDI=
 
  
Currently, the easiest way to run IPython Notebook is on NCI's [[VDI|Virtual Desktop Infrastructure (VDI)]]. For a guide to set up and use VDI, click [https://opus.nci.org.au/display/Help/VDI+User+Guide here].
 
  
Within VDI, open a Linux terminal ('''Applications menu''' -> '''System Tools''' -> '''Terminal''').
 
Inside the Terminal, load the conda environment
 
<syntaxhighlight lang=bash>
 
module use /g/data/hh5/public/modules
 
module load conda
 
  
</syntaxhighlight>
+
= On OOD =
You should then be able to start the notebook with
 
<syntaxhighlight lang=bash>
 
jupyter notebook
 
</syntaxhighlight>
 
 
 
==Connect your local browser==
 
 
 
You can connect the browser on your computer to the jupyter notebook running on vdi once it's started.
 
 
 
You still need to connect to VDI in the usual way. Once the session is started, open a terminal. You need the name of the computer that is running your VDI instance. It is of the form '''vdi-nXX''' where XX is a number. It is possible that this is already displayed in your command line prompt there, otherwise you can run the command:
 
 
 
<syntaxhighlight lang=bash>
 
hostname
 
</syntaxhighlight>
 
 
 
and it will give you the hostname. Remember it.
 
 
 
Next, you load the conda module as above, but tell jupyter to not start a browser:
 
  
<syntaxhighlight lang=bash>
+
Currently, the easiest way to run a Jupyter Notebook is on NCI's [[OOD|Open On-Demand service]]. For a guide to set up and use the OOD, click [https://opus.nci.org.au/display/OOD/Open+OnDemand+(OOD)+Service here].
module use /g/data/hh5/public/modules
 
module load conda
 
jupyter notebook --no-browser
 
</syntaxhighlight>
 
  
You wait for this line:
+
When logging into the OOD, you will have an option to open Jupyter Lab. Please follow the instructions to request the best sized cluster for your work.
  
<syntaxhighlight>
+
&nbsp;
http://localhost:8888/?token=...
 
</syntaxhighlight>
 
  
The 4 digits after the colon (often just 8888, but not always) are the port. We use this number and the hostname to create a new ssh connection to VDI. So in a new terminal session on your computer, run the command:
+
= On Gadi =
  
<syntaxhighlight lang=bash>
+
You can also run a notebook from Gadi's compute nodes using the [https://github.com/coecms/nci_scripts/blob/master/gadi_jupyter gadi_jupyter] script.
ssh userXX@vdi-nXX.nci.org.au -L 8888:localhost:8888
+
=== Pre-requisite ===
</syntaxhighlight>
+
For this method to work, you must become part of the '''hh5''' project at NCI using [https://my.nci.org.au/mancini/project/hh5 my.nci.org.au].
  
Of course, you need to replace '''userXX''' with your NCI username, '''vdi-nXX''' with the hostname, and ''both'' instances of '''8888''' with the actual port number.
+
This project will give you access to [[Conda|conda environments]] for Python managed by the CMS team.
  
Once you've done that, you can copy the full line that you got from jupyter notebook (the one '''<nowiki>http://localhost:8888/?token=...</nowiki>''' (including the full token) into your browser of choice.
+
=== Setting Up SSH ===
 
 
=On Gadi=
 
 
 
You can also run a notebook from Gadi's compute nodes using the [https://github.com/coecms/nci_scripts/blob/master/gadi_jupyter gadi_jupyter] script.
 
 
 
== Setting Up SSH ===
 
  
 
You will need to set up SSH keys to use gadi_jupyter
 
You will need to set up SSH keys to use gadi_jupyter
  
Set up the file ~/.ssh/config with something like
+
Create the file ~/.ssh/config with something like the following lines in:
<syntaxhighlight lang='text'>
+
<syntaxhighlight lang="text">
 
Host *.nci.org.au
 
Host *.nci.org.au
 
User abc123 # Your NCI username here
 
User abc123 # Your NCI username here
Line 69: Line 32:
 
Copy your SSH key to gadi. Some computers have a command that can do this automatically - 'ssh-copy-id gadi.nci.org.au'. If not, you need to add the contents of the file '~/.ssh/id_rsa.pub' on your local computer to the end of the file '~/.ssh/authorized_keys' on Gadi.
 
Copy your SSH key to gadi. Some computers have a command that can do this automatically - 'ssh-copy-id gadi.nci.org.au'. If not, you need to add the contents of the file '~/.ssh/id_rsa.pub' on your local computer to the end of the file '~/.ssh/authorized_keys' on Gadi.
  
Enable your SSH key by running the command 'ssh-add', it will ask for the SSH passphrase you entered when you made the key (which may not be your NCI password). If it says 'Could not open a connection to your SSH agent' run 'ssh-agent bash' and then 'ssh-add'.
+
Enable your SSH key by running the command 'ssh-add', it will ask for the SSH passphrase you entered when you made the key (which may not be your NCI password). If it says 'Could not open a connection to your SSH agent', or '‘could not connect to authentication agent', run 'ssh-agent bash' and then 'ssh-add'.
  
 
You can now run './gadi_jupyter'
 
You can now run './gadi_jupyter'
  
==Notes==
+
=== Notes ===
  
* You need to download this script to your own computer and execute there. The script handles the connection.
+
*You need to download this script to your own computer and execute there. The script handles the connection.  
* This job requires an implementation of bash. This is default on MacOS and Linux, but not Windows.
+
*This job requires an implementation of bash. This is default on MacOS and Linux, but not Windows.  
* This will cost SU depending on the queue and the resources requested (default: 1 cores, express queue)
+
*This will cost SU depending on the queue and the resources requested (default: 1 cores, express queue)  
* You also won't have access to the internet to, for example, download data.
+
*You also won't have access to the internet to, for example, download data.  
  
==Running==
+
=== Running ===
  
 
You can download the script from the link above directly, or by running
 
You can download the script from the link above directly, or by running
 
+
<syntaxhighlight lang="bash">
<syntaxhighlight lang='bash'>
 
 
git clone https://github.com/coecms/nci_scripts.git
 
git clone https://github.com/coecms/nci_scripts.git
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 91: Line 53:
  
 
There are several options that you can use when running the script:
 
There are several options that you can use when running the script:
 
+
<syntaxhighlight lang="unknown">
<syntaxhighlight>
 
 
General Options:
 
General Options:
 
     -h:        Print help
 
     -h:        Print help
Line 108: Line 69:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
= Windows Desktops =
+
=== Windows Desktops ===
  
 
To run gadi_jupyter on Windows you'll need Bash and some form of SSH available. This could be from
 
To run gadi_jupyter on Windows you'll need Bash and some form of SSH available. This could be from
  * git bash - https://gitforwindows.org/
+
 
  * cygwin terminal - https://www.cygwin.com/
+
  * git bash - [https://gitforwindows.org/ https://gitforwindows.org/]
 +
  * cygwin terminal - [https://www.cygwin.com/ https://www.cygwin.com/]
  
 
Install one of these, then within the terminal follow the 'Setting up SSH' instructions before running 'gadi_jupyter'. (The terminal should start in your 'My Documents' directory if you need to find the downloaded script)
 
Install one of these, then within the terminal follow the 'Setting up SSH' instructions before running 'gadi_jupyter'. (The terminal should start in your 'My Documents' directory if you need to find the downloaded script)
  
 
[[Category:Python]]
 
[[Category:Python]]

Revision as of 03:09, 16 September 2021


On OOD

Currently, the easiest way to run a Jupyter Notebook is on NCI's Open On-Demand service. For a guide to set up and use the OOD, click here.

When logging into the OOD, you will have an option to open Jupyter Lab. Please follow the instructions to request the best sized cluster for your work.

 

On Gadi

You can also run a notebook from Gadi's compute nodes using the gadi_jupyter script.

Pre-requisite

For this method to work, you must become part of the hh5 project at NCI using my.nci.org.au.

This project will give you access to conda environments for Python managed by the CMS team.

Setting Up SSH

You will need to set up SSH keys to use gadi_jupyter

Create the file ~/.ssh/config with something like the following lines in:

Host *.nci.org.au
User abc123 # Your NCI username here

Create a SSH key by running 'ssh-keygen'. It will ask for a 'passphrase', make sure you enter one, it doesn't need to be the same as your NCI password. Use the default key file name.

Copy your SSH key to gadi. Some computers have a command that can do this automatically - 'ssh-copy-id gadi.nci.org.au'. If not, you need to add the contents of the file '~/.ssh/id_rsa.pub' on your local computer to the end of the file '~/.ssh/authorized_keys' on Gadi.

Enable your SSH key by running the command 'ssh-add', it will ask for the SSH passphrase you entered when you made the key (which may not be your NCI password). If it says 'Could not open a connection to your SSH agent', or '‘could not connect to authentication agent', run 'ssh-agent bash' and then 'ssh-add'.

You can now run './gadi_jupyter'

Notes

  • You need to download this script to your own computer and execute there. The script handles the connection.
  • This job requires an implementation of bash. This is default on MacOS and Linux, but not Windows.
  • This will cost SU depending on the queue and the resources requested (default: 1 cores, express queue)
  • You also won't have access to the internet to, for example, download data.

Running

You can download the script from the link above directly, or by running

git clone https://github.com/coecms/nci_scripts.git

which will download the script into a directory called nci_scripts.

There are several options that you can use when running the script:

General Options:
    -h:         Print help
    -l:         NCI username
    -L:         NCI login node (default 'gadi.nci.org.au')
    -e:         Conda environment

Queue Options:
    -q QUEUE:   Queue name
    -n NCPU:    Use NCPU cpus
    -m MEM:     Memory allocation (default 4*NCPU GB)
    -t TIME:    Walltime limit (default 1 hour)
    -J JOBFS:   Jobfs allocation (default 100 GB)
    -P PROJ:    Submit job under project PROJ

Windows Desktops

To run gadi_jupyter on Windows you'll need Bash and some form of SSH available. This could be from

* git bash - https://gitforwindows.org/
* cygwin terminal - https://www.cygwin.com/

Install one of these, then within the terminal follow the 'Setting up SSH' instructions before running 'gadi_jupyter'. (The terminal should start in your 'My Documents' directory if you need to find the downloaded script)