{"id":2171,"date":"2022-05-31T11:24:10","date_gmt":"2022-05-31T09:24:10","guid":{"rendered":"http:\/\/calculs.univ-cotedazur.fr\/?page_id=2171"},"modified":"2025-04-24T13:52:29","modified_gmt":"2025-04-24T11:52:29","slug":"jupyter-notebooks","status":"publish","type":"page","link":"https:\/\/calculs.univ-cotedazur.fr\/?page_id=2171","title":{"rendered":"Jupyter Notebooks"},"content":{"rendered":"\n<p>Depuis le noeud de login, lancez une session interactive sur un noeud. Par exemple, pour r\u00e9server un coeur et un gpu sur un noeud de la file gpu pendant 5 heures :<\/p>\n\n\n\n<pre class=\"wp-block-verse\">srun -A votre_account_slurm -p gpu --gpus=1 -t 05:00:00 --pty bash -i<\/pre>\n\n\n\n<p>Cr\u00e9ez un environnement conda avec jupyter et activez-le :<\/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>Si vous avez besoin d&rsquo;installer d&rsquo;autres packages Python, vous pouvez le faire avec :<\/p>\n\n\n\n<pre class=\"wp-block-verse\">conda install nom_du_package<\/pre>\n\n\n\n<p>Si vous avez besoin de charger des modules du cluster, chargez-les avec :<\/p>\n\n\n\n<pre class=\"wp-block-verse\">module load nom_du_module<\/pre>\n\n\n\n<p>Choisir un port libre (ici 10002, prendre une valeur entre 1025 et 60000) et pr\u00e9parer la redirection SSH :<\/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>Copiez la sortie de cette commande.<\/p>\n\n\n\n<p>Lancez 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>Dans un second terminal, lancez la commande copi\u00e9e pr\u00e9c\u00e9demment, elle doit \u00eatre similaire \u00e0 :<\/p>\n\n\n\n<p>ssh -NL 10002:gpu01:10002 user1@login-hpc.univ-cotedazur.fr<\/p>\n\n\n\n<p>Rien ne se passe apr\u00e8s la connexion, c&rsquo;est normal.<\/p>\n\n\n\n<p>Ouvrir un navigateur web et y coller l&rsquo;adresse \u00e9crite dans le premier terminal, celle commen\u00e7ant par 127.0.0.1. Par exemple :<\/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>Pour terminer la session Jupyter : CTRL-C dans le terminal 2 fois.<\/p>\n\n\n\n<p>Pour d\u00e9sactiver l&rsquo;environnement Python : <strong>conda deactivate<\/strong><\/p>\n\n\n\n<p>Pour quitter la session interactive : <strong>exit<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Depuis le noeud de login, lancez une session interactive sur un noeud. Par exemple, pour r\u00e9server un coeur et un gpu sur un noeud de la file gpu pendant 5 heures : srun -A votre_account_slurm -p gpu &#8211;gpus=1 -t 05:00:00 &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":140,"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\/2171"}],"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=2171"}],"version-history":[{"count":9,"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/pages\/2171\/revisions"}],"predecessor-version":[{"id":2992,"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/pages\/2171\/revisions\/2992"}],"up":[{"embeddable":true,"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=\/wp\/v2\/pages\/140"}],"wp:attachment":[{"href":"https:\/\/calculs.univ-cotedazur.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}