-
Notifications
You must be signed in to change notification settings - Fork 0
Jupyter notebook
Hurley edited this page May 26, 2020
·
12 revisions
Instructions for launching Jupyter notebook (NB) from cluster. NB should be launched from compute nodes. These instructions is for Mac users.
- Your Mac can only directly connect to the login nodes, but not compute node.
- If you want to launch NB from computes nodes, you have to setup connections between your Mac and the login node (forward tunnel), as well as between the login node and the compute node (reverse tunnel).
- Please setup your own port number, as well as SSL credentials (see below).
- Install Jupyter
- Start by creating a jupyter config file (~/.jupyter/jupyter_notebook_config.py) if one doesn't already exist using:
jupyter notebook --generate-config
- Create SSL credentials using:
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ~/.jupyter/mycert.key -out ~/.jupyter/mycert.pem
- Next, open Python and use the following to generate a password:
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:14488ced102d:c675686a6f3ff455a355cfc2a6faa75683744a89'
- Open the jupyter config file (~/.jupyter/jupyter_notebook_config.py), and make the following changes:
-
c.NotebookApp.ip = '0.0.0.0'
. -
c.NotebookApp.port = 7700
(replacing 7700 with a new, unused port number). -
c.NotebookApp.open_browser = False
. -
c.NotebookApp.password = u'sha1:14488ced102d:c675686a6f3ff455a355cfc2a6faa75683744a89'
(replacing with your hash from above). -
c.NotebookApp.certfile = u'/users/<username>/.jupyter/mycert.pem'
(replacing username with your username). -
c.NotebookApp.keyfile = u'/users/<username>/.jupyter/mycert.key'
(replacing username with your username).
- From sug-login1, submit an interactive job
qsub -I -q <your queue>
(Note: if you want to keep the interactive job alive, you have to usetmux
to create a session on the login node before submitting job. You can't usescreen
, because you'll needscreen
inside the compute node later) - Within app / compute node, create a
screen
to launch NBjupyter-notebook
(or jupyter lab), this gives you the NB url - Create another
screen
Ctrl+a c
to setup reverse tunnelssh -NR <port#>:localhost:<port#> sug-login1
(has to be the same login node as in step 5 below. Also use your own port number) - Detach
Ctrl+a d
- From your Mac, setup forward tunnel
ssh -NL <port#>:localhost:<port#> <username>@sug-login1.hgsc.bcm.edu
(has to be the same login node as in step 3 above) - Now you can access your NB at https://localhost:<port#> (use your own port number, of course). Note that you need to use https and a password to access your notebooks over the web.
- Run notebook forever for free (!!! Warning !!! you do not see this trick from here). After you setup everything and make sure it's up and running, you can just simply kill your job, that's it! The only thing you need to do is after you lose internet connection, you have to redo the forward tunnel from your local computer, but your work still exist and running on the compute node. (!!! Important !!! Please remember which node you launched your notebook, because in case you accidentally kill your notebook from a terminal on the notebook, you have to log back to that specific compute node in order to deactivate / recycle your port id, and it's not fun to try to figure out where you've launched your notebook if you lose track)
a wiki collection