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 14:37] 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 10: | Line 10: | ||
| However using it effectively on the cluster is a bit more complicated... | However using it effectively on the cluster is a bit more complicated... | ||
| - | After [[CHPC quickstart guide | Logging in]] your account | + | After [[CHPC quickstart guide | Logging in]] your account |
| <code bash> | <code bash> | ||
| Line 16: | Line 16: | ||
| </ | </ | ||
| - | ... And then proceed to load the preferred python module as follows: | + | Now proceed to request for an interactive |
| - | <code bash> | + | |
| - | module add chpc/ | + | |
| - | </ | + | |
| - | + | ||
| - | It is important to use an interactive node for this next step. A single core on an interactive node has proven sufficient | + | |
| <code bash> | <code bash> | ||
| Line 28: | Line 23: | ||
| // | // | ||
| - | | + | |
| - | | + | |
| + | -//Advanced interactive | ||
| + | In your interactive compute node, load the preferred python module as follows: | ||
| + | <code bash> | ||
| + | module add chpc/ | ||
| + | </ | ||
| + | |||
| ==== Security ==== | ==== Security ==== | ||
| - | First things first -- 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). | + | 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: | So first one needs a configuration file, this can be done by passing the generate-config parameter to jupyter as follows: | ||
| Line 39: | Line 40: | ||
| <code bash> | <code bash> | ||
| [USERNAME@cnode0010 ~]$ jupyter-notebook --generate-config | [USERNAME@cnode0010 ~]$ jupyter-notebook --generate-config | ||
| - | Writing default config to: / | ||
| </ | </ | ||
| + | |||
| + | **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): | Next you need to generate your password (remember it -- you'll need it when you connect later): | ||
| Line 54: | Line 58: | ||
| </ | </ | ||
| - | Now edit the '' | + | Use the following command to access the " |
| + | Now edit the '' | ||
| + | |||
| < | < | ||
| c.NotebookApp.password = ' | 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. '' | ||
| + | |||