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:50] 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 compute node where a configuration file and security measures will be established. A single core on an interactive node has proven sufficient for this exercise. Request an arbitrary interactive compute node as follows: |
| + | |||
| + | <code bash> | ||
| + | qsub -I -P PROJ0101 -q serial -l select=1: | ||
| + | </ | ||
| + | |||
| + | // | ||
| + | -//" | ||
| + | -// 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]].// | ||
| + | |||
| + | In your interactive compute node, load the preferred python module as follows: | ||
| <code bash> | <code bash> | ||
| module add chpc/ | 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 | + | ==== Security ==== |
| + | |||
| + | You are not the only person on the system, so it is important to set up authentication | ||
| + | |||
| + | So first one needs a configuration file, this can be done by passing the generate-config parameter to jupyter | ||
| <code bash> | <code bash> | ||
| - | qsub -I -P PROJ0101 | + | [USERNAME@cnode0010 ~]$ jupyter-notebook |
| </ | </ | ||
| - | //**Note**:// | + | **Note** |
| - | -//"PROJ0101" | + | -//This writes default config to: / |
| - | | + | -//The output file "jupyter_notebook_config.py" |
| - | -// Record the cnode ID because | + | |
| + | Next you need to generate | ||
| + | <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/ | ||
| + | </ | ||
| + | |||
| + | 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 | ||
| + | -//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> | ||
| + | # | ||
| + | #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 | ||
| + | <code bash> | ||
| + | cat ~/ | ||
| + | </ | ||
| + | |||
| + | Then, again on your local machine, you need to connect to the compute node, i.e. '' | ||
| + | |||
| + | |||
| + | |||