This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
playground:playground [2021/02/23 15:33] msovara [Jupyter / Ipython Notebook] |
playground:playground [2025/04/29 16:06] (current) nmfuphi [Starting a notebook inside a job] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== **Playground Test edits by MSovara** ====== | + | ====== **Edits by MSovara** ====== |
| ===== Jupyter / Ipython Notebook ===== | ===== Jupyter / Ipython Notebook ===== | ||
| Line 24: | Line 24: | ||
| // | // | ||
| -//" | -//" | ||
| - | -//Advanced interactive node settings are found here: [[CHPC quickstart guide | Example interactive job request]].// | ||
| -// Record the cnode ID because you will ssh into that particular compute node when setting up your password.// | -// Record the cnode ID because you will ssh into that particular compute node when setting up your password.// | ||
| + | -//Advanced interactive compute node settings are found here: [[CHPC quickstart guide | Example interactive job request]].// | ||
| - | load the preferred python module as follows: | + | In your interactive compute node, load the preferred python module as follows: |
| <code bash> | <code bash> | ||
| module add chpc/ | module add chpc/ | ||
| </ | </ | ||
| + | ==== Security ==== | ||
| + | |||
| + | You are not the only person on the system, so it is important to set up authentication on your notebook so that not everyone gets access to your notebook (and worse -- your data). | ||
| + | |||
| + | So first one needs a configuration file, this can be done by passing the generate-config parameter to jupyter as follows: | ||
| + | |||
| + | <code bash> | ||
| + | [USERNAME@cnode0010 ~]$ jupyter-notebook --generate-config | ||
| + | </ | ||
| + | |||
| + | **Note** | ||
| + | -//This writes default config to: / | ||
| + | -//The output file " | ||
| + | |||
| + | Next you need to generate your password (remember it -- you'll need it when you connect later): | ||
| + | <code bash> | ||
| + | python | ||
| + | </ | ||
| + | <code python> | ||
| + | from notebook.auth import passwd | ||
| + | passwd() | ||
| + | Enter password: | ||
| + | Verify password: | ||
| + | ' | ||
| + | </ | ||
| + | |||
| + | Use the following command to access the " | ||
| + | Now edit the '' | ||
| + | |||
| + | |||
| + | < | ||
| + | c.NotebookApp.password = ' | ||
| + | </ | ||
| + | |||
| + | **Remember to uncomment it, don't just copy and paste my hash in**. | ||
| + | |||
| + | ==== Starting a notebook inside a job ==== | ||
| + | |||
| + | There might be a cleaner way of doing this... Please let us know if you have one! | ||
| + | |||
| + | **VERY IMPORTANT: | ||
| + | |||
| + | Open a terminal on your local machine and create a '' | ||
| + | |||
| + | < | ||
| + | touch .ssh/config | ||
| + | </ | ||
| + | |||
| + | If your desktop system runs Windows, a simple way to deal with this is to run a unix-like environment inside Windows. | ||
| + | |||
| + | |||
| + | Continue to edit the '' | ||
| + | < | ||
| + | Host cnode* | ||
| + | Hostname %h | ||
| + | User YOURUSERNAME | ||
| + | ProxyCommand ssh YOURUSERNAME@lengau.chpc.ac.za nc %h 22 | ||
| + | LocalForward 8838 localhost: | ||
| + | </ | ||
| + | |||
| + | |||
| + | **Note** | ||
| + | -//Each session will be assigned a different compute node (cnode* changes everytime you request for an interactive compute node session)// | ||
| + | -//Use localForward and localhost port number provided for each different session.// | ||
| + | |||
| + | Ultimately, what this will do is allow you to '' | ||
| + | |||
| + | < | ||
| + | ssh cnode* | ||
| + | </ | ||
| + | |||
| + | You should be prompted for your password, twice. This is because the '' | ||
| + | |||
| + | You are now ready to roll... | ||
| + | |||
| + | In your browser go to: http:// | ||
| + | |||
| + | The jobscript will look something like: | ||
| + | <file bash jupyter.qsub> | ||
| + | #!/bin/bash | ||
| + | #PBS -P SHORTNAME | ||
| + | #PBS -q serial | ||
| + | #PBS -l select=1: | ||
| + | #PBS -l walltime=08: | ||
| + | #PBS -N Jupyter | ||
| + | #PBS -m abe | ||
| + | #PBS -M YOUR@EMAIL.ADDRESS | ||
| + | |||
| + | module add chpc/ | ||
| + | |||
| + | JUPYTERPORT=8838 | ||
| + | |||
| + | hostname > ~/ | ||
| + | |||
| + | jupyter-notebook --port=${JUPYTERPORT} --no-browser | ||
| + | </ | ||
| + | |||
| + | If you submit that job and wait for it to start running then you can check which host the session is running on with: | ||
| + | <code bash> | ||
| + | cat ~/ | ||
| + | </ | ||
| + | |||
| + | Then, again on your local machine, you need to connect to the compute node, i.e. '' | ||
| + | |||
| + | |||
| + | |||
| - | d. | ||