{"id":2288,"date":"2022-07-21T10:06:01","date_gmt":"2022-07-21T08:06:01","guid":{"rendered":"http:\/\/calculs.univ-cotedazur.fr\/?page_id=2288"},"modified":"2025-04-24T13:53:41","modified_gmt":"2025-04-24T11:53:41","slug":"jupyter-notebooks","status":"publish","type":"page","link":"https:\/\/calculs.univ-cotedazur.fr\/?page_id=2288&lang=en","title":{"rendered":"Jupyter Notebooks"},"content":{"rendered":"\n<p>From the login node, launch an interactive session on a compute node. For example, to request one core and one GPU during 5 hours on the gpu queue:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">srun -A your_slurm_account -p gpu --gpus=1 -t 05:00:00 --pty bash -i<\/pre>\n\n\n\n<p>Create a conda environment including jupyter and activate it:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">module load miniconda\nconda create --prefix \/workspace\/$USER\/jupyter_env python=3.8 jupyter\nsource activate \/workspace\/$USER\/jupyter_env<\/pre>\n\n\n\n<p>If you need to install other Python packages, you can do it this way:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">conda install package_name<\/pre>\n\n\n\n<p>If you need to load some of the cluster modules, do it with:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">module load module_name<\/pre>\n\n\n\n<p>Pick a free port (here 10002, the value should be between 1025 and 60000) and set the SSH redirection:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">export myport=10002\necho \"ssh -NL $myport:$(hostname):$myport $USER@login-hpc.univ-cotedazur.fr\"<\/pre>\n\n\n\n<p>Copy the output of this command.<\/p>\n\n\n\n<p>Launch Jupyter :<\/p>\n\n\n\n<pre class=\"wp-block-verse\">jupyter-notebook --no-browser --port=$myport --ip='0.0.0.0'<\/pre>\n\n\n\n<p>In a second terminal, execute the previously copied command, it should look like:<\/p>\n\n\n\n<p>ssh -NL 10002:gpu01:10002 user1@login-hpc.univ-cotedazur.fr<\/p>\n\n\n\n<p>Nothing happens after a successful connection.<\/p>\n\n\n\n<p>Open a web browser and paste the URL written in the first terminal, the one that starts with 127.0.0.1. For example:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">Jupyter Notebook 6.4.11 is running at:\n<strong>http:\/\/127.0.0.1:10002\/?token=fd205eb91399103f95d1bc80d0400bf0536442810ba3df1a<\/strong><\/pre>\n\n\n\n<p>To end the Jupyter session: CTRL-C twice in your terminal.<\/p>\n\n\n\n<p>To deactivate your Python environment: <strong>conda deactivate<\/strong><\/p>\n\n\n\n<p>To quit the interactive session: <strong>exit<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>From the login node, launch an interactive session on a compute node. For example, to request one core and one GPU during 5 hours on the gpu queue: srun -A your_slurm_account -p gpu &#8211;gpus=1 -t 05:00:00 &#8211;pty bash -i Create &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":580,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/pages\/2288"}],"collection":[{"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2288"}],"version-history":[{"count":2,"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/pages\/2288\/revisions"}],"predecessor-version":[{"id":2993,"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/pages\/2288\/revisions\/2993"}],"up":[{"embeddable":true,"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/pages\/580"}],"wp:attachment":[{"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}