This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
tipsntricks:ipython_notebook [2021/03/11 14:36] ccrosby [Jupyter / Ipython Notebook] |
tipsntricks:ipython_notebook [2024/06/21 16:01] (current) wikiadmin [Jupyter / Ipython Notebook] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Jupyter / Ipython Notebook ===== | ===== Jupyter / Ipython Notebook ===== | ||
| - | Jupyter is installed in most of the python | + | Jupyter is a commonly |
| <code bash> | <code bash> | ||
| jupyter-notebook | jupyter-notebook | ||
| </ | </ | ||
| - | 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 check for your preferred python version as follows: | + | After [[http:// |
| <code bash> | <code bash> | ||
| Line 14: | Line 14: | ||
| </ | </ | ||
| - | Now proceed to request | + | You can now request an interactive compute node to establish |
| <code bash> | <code bash> | ||
| - | qsub -I -P PROJ0101 -q serial -l select=1: | + | qsub -I -P PROJ0101 -q serial -l select=1: |
| </ | </ | ||
| // | // | ||
| - | -//" | + | -// Kindly replace |
| - | -// Record | + | -// Make sure to record |
| -//Advanced interactive compute node settings are found here: [[http:// | -//Advanced interactive compute node settings are found here: [[http:// | ||
| - | Certain users may want to | + | Certain users may require nodes with more memory in order to post-process large data sets. You may use a " |
| - | In your interactive | + | <code bash> |
| + | qsub -I -P PROJ0101 -q bigmem -l select=1: | ||
| + | </ | ||
| + | |||
| + | In your interactive node, load the preferred python module as follows: | ||
| <code bash> | <code bash> | ||
| module add chpc/ | module add chpc/ | ||
| Line 34: | Line 38: | ||
| ==== Security ==== | ==== 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). | + | 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 43: | Line 47: | ||
| **Note** | **Note** | ||
| - | -//This writes default config to: / | + | -//This writes |
| - | -//The output file " | + | -//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 58: | Line 62: | ||
| </ | </ | ||
| - | Use the following command to access the " | + | Your password hash will be different. |
| - | Now edit the '' | + | |
| + | Exit python and then use the following command to access the " | ||
| + | <code bash> | ||
| + | cd .jupyter/ | ||
| + | </ | ||
| + | |||
| + | Now edit the file '' | ||
| < | < | ||
| + | vim jupyter_notebook_config.py | ||
| c.NotebookApp.password = ' | c.NotebookApp.password = ' | ||
| </ | </ | ||
| - | **Remember to uncomment it, don't just copy and paste my hash in**. | + | **Remember to uncomment it, and copy and paste your own hash in**. |
| ==== Starting a notebook inside a job ==== | ==== Starting a notebook inside a job ==== | ||
| Line 74: | Line 84: | ||
| **VERY IMPORTANT: | **VERY IMPORTANT: | ||
| - | Open a terminal on your local machine | + | Open a terminal on your **local** workstation |
| < | < | ||
| Line 80: | Line 90: | ||
| </ | </ | ||
| - | If your desktop system runs Windows, a simple way to deal with this is to run a unix-like environment inside Windows. | + | If your desktop system runs Windows, a simple way to deal with this is to run a unix-like environment inside Windows. |
| - | Continue | + | Find, |
| + | < | ||
| + | ls -al | ||
| + | </ | ||
| + | ... and continue | ||
| < | < | ||
| Host cnode* | Host cnode* | ||
| Line 89: | Line 103: | ||
| User YOURUSERNAME | User YOURUSERNAME | ||
| ProxyCommand ssh YOURUSERNAME@lengau.chpc.ac.za nc %h 22 | ProxyCommand ssh YOURUSERNAME@lengau.chpc.ac.za nc %h 22 | ||
| - | LocalForward | + | LocalForward |
| + | Host fat* | ||
| + | Hostname %h | ||
| + | User YOURUSERNAME | ||
| + | ProxyCommand ssh YOURUSERNAME@lengau.chpc.ac.za nc %h 22 | ||
| + | LocalForward 8888 localhost: | ||
| </ | </ | ||
| + | |||
| + | |||
| + | Remember to replace " | ||
| At this point you may not know what the LocalForward and localhost port numbers are so, on the cluster in the interactive node you had opened earlier type: | At this point you may not know what the LocalForward and localhost port numbers are so, on the cluster in the interactive node you had opened earlier type: | ||
| Line 96: | Line 118: | ||
| jupyter-notebook --no-browser | jupyter-notebook --no-browser | ||
| </ | </ | ||
| - | Edit given port number into LocalForward and localhost above | + | Edit the given port number into LocalForward and localhost above |
| **Note** | **Note** | ||
| Line 102: | Line 124: | ||
| -//Confirm the localForward and localhost port numbers provided for each different session.// | -//Confirm the localForward and localhost port numbers provided for each different session.// | ||
| - | In your local terminal '' | + | In your local terminal '' |
| < | < | ||
| - | ssh cnode* | + | ssh cnode1234 |
| </ | </ | ||
| - | You should be prompted for your password, twice. This is because the '' | + | You should be prompted for your CLUSTER |
| You are now ready to roll... | You are now ready to roll... | ||
| - | In your browser go to: http:// | + | In your browser go to: http:// |
| The jobscript will look something like: | The jobscript will look something like: | ||
| <file bash jupyter.qsub> | <file bash jupyter.qsub> | ||
| #!/bin/bash | #!/bin/bash | ||
| - | #PBS -P SHORTNAME | + | #PBS -P ERTH1234 |
| #PBS -q serial | #PBS -q serial | ||
| - | #PBS -l select=1: | + | #PBS -l select=1: |
| #PBS -l walltime=08: | #PBS -l walltime=08: | ||
| #PBS -N Jupyter | #PBS -N Jupyter | ||
| Line 127: | Line 149: | ||
| module add chpc/ | module add chpc/ | ||
| - | JUPYTERPORT=8838 # you could change this too, if you wanted to. | + | JUPYTERPORT=8888 # you could change this too, if you wanted to. |
| hostname > ~/ | hostname > ~/ | ||
| Line 139: | Line 161: | ||
| </ | </ | ||
| - | Then, again on your local machine, you need to connect to the compute node, i.e. '' | + | Then, again on your local machine, you need to connect to the allocated |
| ==== Running Jupyter on a GPU node ==== | ==== Running Jupyter on a GPU node ==== | ||