{"id":9199,"date":"2025-04-01T16:33:19","date_gmt":"2025-04-01T15:33:19","guid":{"rendered":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/?page_id=9199"},"modified":"2026-04-16T11:18:32","modified_gmt":"2026-04-16T10:18:32","slug":"jupyter-notebook-slurm","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/applications\/jupyter-notebook-slurm\/","title":{"rendered":"Jupyter Notebook (slurm)"},"content":{"rendered":"<h2>Overview<\/h2>\n<p><a href=\"http:\/\/jupyter.org\/\">Jupyter Notebook<\/a> is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text.<\/p>\n<p>Please read carefully the instructions below when connecting a web-browser to your jupyter notebook on the CSF (slurm) &#8211; there are some extra steps needed that you would not normally do if you were running a jupyter notebook on your local desktop\/laptop (or the <a href=\"http:\/\/ri.itservices.manchester.ac.uk\/virtual-desktop-service\/x2go\/\">x2go virtual desktop<\/a> if using that).<\/p>\n<p>It is possible to run jupyter notebook on the Nvidia GPU nodes. However, <strong>you need to request being added to the relevant group to access <a href=\"\/csf3\/batch\/gpu-jobs\/\">GPUs<\/a> before you can run Jupyter Notebook on them.<\/strong><\/p>\n<h2>Restrictions on use<\/h2>\n<p>There are no restrictions on accessing this software.<\/p>\n<h2>Set up procedure<\/h2>\n<p>To access the software you must first load the modulefile:<\/p>\n<pre class =\"slurm\">\r\nmodule load apps\/binapps\/jupyter-notebook\/any    # loads Anaconda3 2024.10 by default \r\n<\/pre>\n<p>If you&#8217;ve not already loaded a specific anaconda python modulefile, the above &#8220;any&#8221; modulefile will automatically load the latest Anaconda3 Python modulefile for you (jupyter is provided by Anaconda Python). If you wish to use a specific version of Anaconda python, <em>you<\/em> should load its modulefile first.<\/p>\n<h2>Initial Setup<\/h2>\n<p>No initial setup is needed to run jupyter notebooks.<\/p>\n<p>It is possible, if you wish, to password protect your notebooks, which can be done using the commands below. But this is optional. By default a jupyter notebook will present you with a login page when you fist visit the notebook with your web-browser. You can setup a password via <em>that<\/em> webpage. You can also use the <em>token<\/em>-based security which the notebook uses if you don&#8217;t set up a password. This requires you to enter a random string of letters and numbers, which are reported in the job output <code>.out<\/code> file for the job running the notebook.<\/p>\n<p>Hence only <em>you<\/em> can access your notebooks when they are running on the CSF, even if you don&#8217;t set up a notebook password.<\/p>\n<p><strong>Our recommendation is to use the default token-based authentication and not bother setting up a password for the notebooks.<\/strong><\/p>\n<h3>Optional Setup<\/h3>\n<p>After loading the Jupyter Notebook modulefile, run the following on the login node:<\/p>\n<pre class=\"slurm\">jupyter-notebook --generate-config\r\n\r\n# It will output:\r\nWriting default config to: \/mnt\/iusers01\/<em>xy01<\/em>\/<em>mabcxyz1<\/em>\/.jupyter\/jupyter_notebook_config.py\r\n   #\r\n   # The <em>xy01<\/em> group and <em>mabcxyz1<\/em> username will differ\r\n<\/pre>\n<p>The command has reported where it has generated the configuration file (within your home area). The file is at (where <code>~<\/code> means your <em>home<\/em> directory):<\/p>\n<pre>~\/.jupyter\/jupyter_notebook_config.py\r\n<\/pre>\n<details>\n<summary class=\"h3\">Optional Password Protection (skip this) [click to expand]<\/summary>\n<p>Password protecting the access to your running notebooks is optional. If you do <em>not<\/em> set a password then the notebooks are still only accessible by you &#8211; a notebook&#8217;s webpage will ask for a <em>token<\/em> (a random set of letters and numbers) to be entered, which only you can get from the job output <code>slurm-<em>NNNNN<\/em>.out<\/code> file (see below). It is very unlikely another user would be able to guess this token!<\/p>\n<p>In fact we recommend that you <strong>skip password protection<\/strong> and use the token method instead &#8211; i.e., you don&#8217;t need to do anything here and can jump straight to <a href=\"#running\">running the notebook<\/a>.<\/p>\n<p>If you do wish to create a password to protect access to your notebooks when the server is running, <strong>do NOT use your central IT password<\/strong>. This is not a terribly secure method of protecting your notebooks but will offer some protection. Please do NOT use a password that is used on other systems or is valuable to you.<\/p>\n<p>Run the following on the login node:<\/p>\n<pre class=\"slurm\">\r\npython -c \"from jupyter_server.auth import passwd; print(passwd())\"\r\n\r\n# It will display:\r\nEnter password: <strong>Enter your new notebook password and press [return]<\/strong>\r\nVerify password: <strong>Enter the same password again and press [return]<\/strong>\r\n<em>argon2:$argon2id$v=19$m=10240,t=10,p=8$X4CyNDaKJw2rZhCQatsjbw$ZDUmJx5hfcUNsmGOBxNn3EfYa1SL3hzvt+2ZdU9rQDQ<\/em>\r\n  #\r\n  # This line is the result (yours will be different).\r\n  # We need to copy this in to the config file generated earlier.\r\n<\/pre>\n<p>Take a copy of the above line. Now edit the config file generated earlier:<\/p>\n<pre class='slurm'>xnedit ~\/.jupyter\/jupyter_notebook_config.py\r\n  #\r\n  # Could also use nano or vi or emacs editors\r\n<\/pre>\n<p>Search the file for a line that looks like:<\/p>\n<pre class='slurm'># c.ServerApp.password = ''\r\n<\/pre>\n<p>and change it to be:<\/p>\n<pre class='slurm'>c.ServerApp.password = '<em>argon2:$argon2id$v=19$m=10240,t=10,p=8$X4CyNDaKJw2rZhCQatsjbw$ZDUmJx5hfcUNsmGOBxNn3EfYa1SL3hzvt+2ZdU9rQDQ<\/em>'\r\n#\r\n# Notice we have remove the '#' at the start\r\n<\/pre>\n<p>where the <code>argon2:....<\/code> is copied from the output generated earlier.<\/p>\n<p>Now search the config file for a line that looks like:<\/p>\n<pre class='slurm'># c.ServerApp.ip = 'localhost'\r\n<\/pre>\n<p>Change this to be:<\/p>\n<pre class='slurm'>c.ServerApp.ip = '*'\r\n#\r\n# Notice we have remove the '#' at the start\r\n<\/pre>\n<p>When you connect to a jupyter notebook server with a web-browser you will be asked for the password you specified earlier. Note that this does NOT use <code>https<\/code> (at the moment). So you should NOT use a password that is of value to you.<\/p>\n<p>That is all of the setup we need to do. You can now start a jupyter-notebook job as described below.<br \/>\n<\/details>\n<p>We recommend that you <strong>skip password protection<\/strong> and use the token method instead &#8211; i.e., you don&#8217;t need to do anything here and can jump straight to <a href=\"#running\">running the notebook<\/a>.<\/p>\n<p><a name=\"running\"><\/a><\/p>\n<h2>Running the application<\/h2>\n<p>Your jupyter notebook will run in the batch system on a compute node. The basic procedure is as follows:<\/p>\n<ol class=\"gaplist\">\n<li>Submit a jupyter notebook job on the CSF and wait for it to run. We do this using a helper script named <code>jupyter-notebook-csf<\/code> run on the login node &#8211; no need to write a jobscript yourself! You can also use the command: <code>jupyter-notebook-csf-slurm<\/code> (it is the same script as <code>jupyter-notebook-csf<\/code>)<\/li>\n<li>On your local desktop\/laptop (or the <a href=\"http:\/\/ri.itservices.manchester.ac.uk\/virtual-desktop-service\/x2go\/\">x2go virtual desktop<\/a> if using that) create an SSH tunnel to the CSF compute node running your jupyter notebook.<\/li>\n<li>On your local desktop\/laptop (or the <a href=\"http:\/\/ri.itservices.manchester.ac.uk\/virtual-desktop-service\/x2go\/\">x2go virtual desktop<\/a> if using that) connect a web-browser to the SSH tunnel &#8211; it will then connect to the CSF job.<\/li>\n<\/ol>\n<p>Using an SSH tunnel may seem like a complicated method but it is the only way to reach the CSF compute node where your jupyter job is running. It also improves security &#8211; any traffic between your web-browser and the jupyter server will be encrypted.<\/p>\n<p>The above procedure is now shown in detail below.<\/p>\n<h3><code>jupyter-notebook-csf<\/code> helper script<\/h3>\n<p>Note that you can also use the command: <code>jupyter-notebook-csf-slurm<\/code> (it is the same script as <code>jupyter-notebook-csf<\/code>).<\/p>\n<p>The <code>jupyter-notebook-csf<\/code> helper script mentioned above (used to submit a batch job from the login node) accepts the following flags:<\/p>\n<pre class=\"slurm\">\r\njupyter-notebook-csf [-p PARTITION] [-n NUMCORES] [-t TIMELIMIT] [-m 32|46|62|125] [-g NUMGPUS]   [-j] [-k] [-P PORTNUM] [-c JOBID] [-T JOBID]\r\n\r\nStarts a Jupyter Notebook server on a compute node.\r\n\r\n-p PARTITION -- Run in PARTITION. Default is serial partition.\r\n                -----------------------------------------------------------------------------------------\r\n                PARTITION NAME  - DESCRIPTION\r\n                -----------------------------------------------------------------------------------------\r\n                multicore       - Run on the AMD nodes, 2-168 cores\r\n                multicore_small - Run on the Intel nodes, 2-32 cores\r\n                serial          - Intel nodes only, will run using 1 core\r\n                himem           - Run on high memory nodes! 1-32 cores, -m MUST BE SPECIFIED (See below)\r\n                vhimem          - RESTRICTED ACCESS Run on very high memory node (126GB\/core) 1-32cores, -m must be specified\r\n                gpuV            - !!! NO LONGER AVAILABLE !!!\r\n                gpuA            - Run on the Nvidia A100 80GB GPU nodes IF YOU HAVE ACCESS TO SUCH NODES! 1-48 cores\r\n                gpuA40GB        - Run on the Nvidia A100 40GB GPU nodes IF YOU HAVE ACCESS TO SUCH NODES! 1-48 cores\r\n                gpuL            - Run on the Nvidia L40s GPU nodes IF YOU HAVE ACCESS TO SUCH NODES! 1-48 cores cores\r\n                -----------------------------------------------------------------------------------------------------\r\n-n NUMCORES  -- Request NUMCORES cores. Default is 1, max 168.\r\n-t TIMELIMIT -- Time MUST be specified (default 1 day, max 7 days).\r\n                Acceptable time formats include 'minutes', 'minutes:seconds', 'hours:minutes:seconds', 'days-hours', 'days-hours:minutes'\r\n-m 32        -- Run on a 32GB\/core (512GB) node (max 16 cores).\r\n-m 46        -- Run on a 46GB\/core (1500GB or 1.5TB) node (max 32 cores).\r\n-m 62        -- Run on a 62GB\/core (2000GB or 2TB) node (max 32 cores).\r\n-m 125       -- run on a 125GB\/core (4000GB or 4TB) node (max 32 cores). [REQUEST ACCESS BEFORE USING]\r\n                If no -m flag given, the system will choose an ordinary compute node for you.\r\n                If no '-p PARTITION' flag given, will default to the 'himem' or 'vhimem' partition.\r\n                NOTE: you cannot use the -m flag if running on GPU nodes (-g flag).\r\n-j           -- Generate the jobscript but DO NOT submit it. Debugging only.\r\n-k           -- Keep the jobscript file after it has been submitted. Deleted by default.\r\n                The autogenerated jobscript is not very useful to you.\r\n-P PORTNUM   -- Port number from which to start searching for a free port for the\r\n                the notebook server to listen on. Default starting port is 8888.\r\n-g NUMGPUS   -- Run on the Nvidia GPU nodes IF YOU HAVE ACCESS TO SUCH NODES!\r\n                Depending on your level of access you can request 1 -- 4 GPUs\r\n                The '-p PARTITION' flags are required to specify the type of GPU (see above.)\r\n                NOTE: you cannot use a GPU flag if running on himem nodes (-m flag).\r\n\r\nTo check whether a jupyter notebook job is running:\r\n\r\n-c JOBID     -- report squeue status of job\r\n\r\nOnce a job is running, get info about accessing the notebook via a web-browser:\r\n\r\n-T JOBID     -- read the job slurm.out file and report the token used for authentication.\r\n                You can only do this AFTER the jupyter notebook batch job has started.\r\n                This is to help with logging in to the notebook in a web-browser.\r\n\r\n-h           -- Display this help.\r\n\r\nCheck the slurm.out file for instructions on how to connect\r\na web-browser to the server once the job runs.\r\n<\/pre>\n<p>We now go through the complete steps to using a Jupyter Notebook.<\/p>\n<h3>Complete Steps to Running a Jupyter Notebook<\/h3>\n<ol>\n<li>Submit a jupyter notebook job using the helper script run on the CSF login node:\n<pre class=\"slurm\">module load apps\/binapps\/jupyter-notebook\/any\r\n\r\n# Run <em>one<\/em> of the following examples on the login node:\r\n\r\njupyter-notebook-csf                               # Submit 1-core serial job w\/ 1 hour timelimt \r\njupyter-notebook-csf -p multicore -n 4 -t 0-6      # Submit a parallel 4-core job using the AMD nodes w\/ 6 hour timelimit \r\njupyter-notebook-csf -p highmem -n 4 -m 32 -t 0-6  # As above but requests 32GB\/core RAM, runs on Intel himem node\r\njupyter-notebook-csf -p gpuA -n 12 -g 1 -t 0-6     # 12 core parallel job using 1xA100 GPU\r\n<\/pre>\n<p>The output from the helper script can be one of two things:<\/p>\n<ol>\n<li>If the job runs straight away in the batch system you&#8217;ll see:\n<pre class=\"slurm\">\r\nValid time format: 6:00:00\r\n4 cores selected\r\nSubmitted batch job 1518\r\nChecking if job has already started...\r\n..\r\nPLEASE READ THE FOLLOWING:\r\nStarting jupyter-notebook on node1260 port 8888\r\n\r\nYou must now ssh in to the CSF3 from your local machine and tunnel\r\nto the backend compute node. Use the following command on *your*\r\ncomputer (not on the CSF3):\r\n\r\n  ssh -L 8888:node<em>1260<\/em>:8888 <em>username<\/em>@csf3.itservices.manchester.ac.uk\r\n\r\nYou should then start a web-browser on *your* computer and browse to:\r\n\r\n  http:\/\/localhost:8888\r\n\r\nIf you are asked for a token to login to the notebook, have a look in\r\nthis job's .out file for the token by running the following command:\r\n\r\n  jupyter-notebook-csf -T 1518\r\n\r\n(you should only run the above command *after* the batch job has started)\r\n\r\nIf you press the 'Quit' button in your notebook's web-page it will terminate the batch job.\r\nIf you press the 'Logout' button in your notebook's web-page or simply close the web-browser\r\nthen you *must* run the following command on the CSF3 to terminate the Jupyter batch job:\r\n\r\n  scancel 1518\r\n\r\nDon't forget to log out of your tunnelled ssh session.\r\n<\/pre>\n<p>This means that the jupyter-notebook job started immediately on a compute node so you are able to proceed with setting up the SSH tunnel from your local computer (or the <a href=\"http:\/\/ri.itservices.manchester.ac.uk\/virtual-desktop-service\/x2go\/\">x2go virtual desktop<\/a> if using that) to the CSF and then connecting your web-browser to it by following the instructions in the above message (see below for an example).<\/li>\n<li>If the job doesn&#8217;t run immediately but waits in the batch queue:\n<pre class=\"slurm\">\r\nValid time format: 6:00:00\r\nSubmitted batch job 1528\r\nChecking if job has already started...\r\n....................\r\n\r\nThe job is probably still waiting to run. Here is your squeue output....\r\n\r\n          JOBID PRIORITY  PARTITION NAME            USER     ST SUBMIT_TIME    START_TIME     TIME        NODES  CPUS NODELIST(REASON)\r\n           1528 0.0000002 gpuA      jnotebook.25040 username PD 02\/04\/25 17:11 02\/04\/25 17:11             1      12 (Priority)\r\n\r\nYou *cannot* connect a web-browser to the CSF3 until the job runs.\r\nPlease be patient.\r\n\r\nTo check your job's status, run:\r\n\r\n   jupyter-notebook-csf -c 1528\r\n\r\n   (or simply run 'squeue')\r\n\r\nWhen the job eventually runs you should then run the following command\r\nto get further instructions on how to connect your web-browser to the\r\nJupyter notebook:\r\n\r\n   cat slurm-1528.out\r\n\r\nFollow the instructions given in that file.\r\n\r\n<\/pre>\n<p>Note that the job-ID <strong><code>1528<\/code><\/strong> will be different for your job. The above message means that you must check on your job using the <code>squeue<\/code> command to see when it is running. When it is running you can proceed with the instructions given in the file: <code>slurm-NNNNN.out<em>NNNNN<\/em><\/code> where <em>NNNNN<\/em> is the job-ID of your own job.<\/li>\n<\/ol>\n<\/li>\n<li>Once the notebook job is running you can now set up the SSH tunnel on <em>your<\/em> computer (not the CSF). You&#8217;ll need to <strong>open another terminal window<\/strong> so that you have one <strong>that is NOT logged in to the CSF<\/strong>.For example, if you are on Windows use MobaXterm and press the new tab icon to open a Local Terminal (see image below), if on Mac use the <em>Terminal<\/em> application and if on linux use an Xterm or GNOME Terminal.<br \/>\n<a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/mobaxterm-newtab-red.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-5912\" src=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/mobaxterm-newtab-red.png\" alt=\"MobaXterm new tab\" width=\"700\" srcset=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/mobaxterm-newtab-red.png 855w, https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/mobaxterm-newtab-red-300x81.png 300w, https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/mobaxterm-newtab-red-768x208.png 768w\" sizes=\"(max-width: 855px) 100vw, 855px\" \/><\/a>Then run:<\/p>\n<pre># Run this on <em>your<\/em> computer (PC\/laptop), <strong>NOT in a terminal logged in to the CSF<\/strong>\r\n# The terminal window you run this in (e.g., MobaXterm) must NOT be logged in to the CSF.\r\nssh -L <strong>8888<\/strong>:<strong>node780<\/strong>:<strong>8888<\/strong> <em>username<\/em>@csf3.itservices.manchester.ac.uk\r\n         ^     ^      ^      ^\r\n         |     |      |      |\r\n         |     |      |      +----- use your own central IT username here\r\n         +-----+------+\r\n               |\r\n               |\r\n               +---------- These values (port numbers and compute node name) are reported in\r\n                           the above output when you submitted the notebook job. You should\r\n                           use the values appropriate to your job (the port will likely be\r\n                           8888 but could be different. The node name will very likely be\r\n                           a different node number).\r\n                           Note also, some high-memory nodes as named <strong>h<\/strong>node<em>NNN<\/em>.\r\n\r\n<\/pre>\n<\/li>\n<li>Now start a web-browser on <em>your PC<\/em> and browse to:\n<pre>http:\/\/localhost:<strong>8888<\/strong>\r\n                   #\r\n                   # Use the same port number as used above\r\n<\/pre>\n<\/li>\n<li>You should be taken to the Jupyter Notebook login page. If you created a password earlier (most people don&#8217;t) then enter it in the webpage to access the jupyter notebook webpage. If you did <em>not<\/em> set up a password, the notebook&#8217;s webpage will indicate that token authentication is in use. You will need to get the notebook&#8217;s <em>token<\/em> (see below).<\/li>\n<\/ol>\n<p>You can now use the Jupyter Notebook through your own web-browser. Any code you enter is executed on the CSF compute node on which the Jupyter Notebook server is running. Hence you should ensure your code uses the correct number of cores you reserved when you submitted the notebook job.<\/p>\n<h3>Obtaining the Notebook Token<\/h3>\n<p>When you visit your notebook in a web-browser you may be asked for a <em>token<\/em> if you didn&#8217;t set up a password. The token is similar to a random auto-generated password.<\/p>\n<p>To find out what the token is for your notebook run the following command on the login node when your notebook is running and <strong>after<\/strong> you have pointed a web-browser at the notebook page (you&#8217;ll see the login page):<\/p>\n<pre># Run this on the CSF login node, in the folder where you submitted the jupyter job from\r\njupyter-notebook-csf -T <em>JOBID<\/em>\r\n<\/pre>\n<p>where <em>JOBID<\/em> is the job id of your notebook job (run <code>squeue<\/code> if you are unsure). You should see lines similar to the following:<\/p>\n<pre>\r\nAuthentication token for your notebook is <strong>3827b48cc078578c5b50232f7835e6cb809c128a25a74294<\/strong>\r\nType it in to the webpage at: http:\/\/localhost:8888\/  (if asked for a token)\r\nOR browse to http:\/\/localhost:8888\/?token=<strong>3827b48cc078578c5b50232f7835e6cb809c128a25a74294<\/strong>\r\n<\/pre>\n<p><strong>Option 1:<\/strong> You can either browse directly to the notebook by appending the <code>?token=...<\/code> text to the <em>localhost<\/em> URL we used above:<\/p>\n<pre>\r\n# Go directly to your notebook\r\nhttp:\/\/localhost:8888<strong>\/?token=<em>3827b48cc078578c5b50232f7835e6cb809c128a25a74294<\/em><\/strong>\r\n                   #                    #\r\n                   #                    # Use the token shown in <em>your<\/em> output above, not this example!\r\n                   #                                   \r\n                   # Use the same port number as used above\r\n<\/pre>\n<p><strong>Option 2:<\/strong> or copy the token part of the address:<\/p>\n<pre>\r\n# Type this into to the box at the top of the page at http:\/\/localhost:8888\r\n<strong>3827b48cc078578c5b50232f7835e6cb809c128a25a74294<\/strong>\r\n             #\r\n             # Use the token shown in <em>your<\/em> output above, not this example!\r\n<\/pre>\n<p>in to the type-in box in the notebook&#8217;s login web-page &#8211; use the box at the top of the screen, as show below:<\/p>\n<p><a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-login-red.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-login-red.png\" alt=\"Jupyter Noteboook Login Page\" width=\"618\" height=\"787\" class=\"alignnone size-full wp-image-9819\" srcset=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-login-red.png 618w, https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-login-red-236x300.png 236w\" sizes=\"auto, (max-width: 618px) 100vw, 618px\" \/><\/a><\/p>\n<h3>Example Notebook<\/h3>\n<p>Once you have connected to your notebook, try the following in your web-browser:<\/p>\n<ol>\n<li>Select <code>New -- Python3<\/code> to start a new python notebook.<\/li>\n<li>Enter the following code in the first <em>cell<\/em> (see image below):\n<pre>import os\r\nfile=os.getenv(\"JUPYTER_HOME\")+\"\/example_job\/mandelbrot.py\"\r\n%load $file\r\n<\/pre>\n<p><a href=\"\/csf3\/wp-content\/uploads\/jupyter-example-notebook-load-small.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1674\" src=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-example-notebook-load-small.png\" alt=\"Load a python file in to a notebook\" width=\"668\" height=\"193\" srcset=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-example-notebook-load-small.png 668w, https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-example-notebook-load-small-300x87.png 300w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/a><\/li>\n<li>Press the <code>Run<\/code> button <em>twice<\/em> &#8211; firstly to load the <code>mandelbrot.py<\/code> in to the notebook. Then secondly to execute the notebook code.<\/li>\n<li>You should see a Mandelbrot fractal image in your web-browser. The code was executed in the batch job running on the compute node!<br \/>\n<a href=\"\/csf3\/wp-content\/uploads\/jupyter-example-notebook-mandelbrot-result.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1669\" src=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-example-notebook-mandelbrot-result.png\" alt=\"Mandelbrot notebook result\" width=\"512\" height=\"297\" srcset=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-example-notebook-mandelbrot-result.png 512w, https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-example-notebook-mandelbrot-result-300x174.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/li>\n<\/ol>\n<h3>Stopping a Notebook<\/h3>\n<p>When you have finished with the jupyter notebook you can either:<\/p>\n<ul class=\"gaplist\">\n<li>Press the <code>Quit<\/code> button in the notebook&#8217;s web-page to stop the notebook and terminate the jupyter batch job on the CSF<\/li>\n<li>Press the &#8216;Logout&#8217; button in the notebook&#8217;s web-page, or simply close your web-browser and, if you no longer want to connect back to the notebook, remove the job that is running on the CSF compute node using the usual <code>qdel<\/code> command:\n<pre># On the CSF login node:\r\nscancel <strong>83873<\/strong>\r\n      #\r\n      # Change the job id to be that of your notebook job.\r\n      # If unsure, run 'squeue' to see a list of your jobs.\r\n<\/pre>\n<\/li>\n<li>Don&#8217;t forget to log out of the window running the ssh tunnel created earlier.<\/li>\n<\/ul>\n<p>Please do remember to stop your CSF server job via the <code>Quit<\/code> button or <code>Logout<\/code> button followed by the <code>qdel<\/code> command. Logging out of the notebook in your web-browser does NOT stop the CSF job. You MUST do this using <code>qdel<\/code> to free up the compute node for other users.<\/p>\n<h2>Using your Conda Environments with Jupyter Notebooks<\/h2>\n<p>If you have a personal conda environment (e.g., <code>myenv<\/code>) which you would like to use in jupyter, please do the following on the login node. It will install a package inside your conda environment to allow it to work with jupyter notebooks.<\/p>\n<pre># Add a package to your conda env to allow it to be used with jupyter notebooks:\r\n\r\n# You must do this via an interactive session, to have access to the outside world.\r\n# This is needed to download a package. So, on the CSF login node:\r\nsrun -p interactive -t 60 --pty \/bin\/bash -l\r\n  #\r\n  # Wait until you've been logged in to a compute node, then:\r\n\r\n# If you used Anaconda python to create the <em>conda env<\/em> then you should\r\n# load the modulefile for that version of Anaconda now. For example:\r\nmodule load apps\/binapps\/anaconda3\/2024.10        # Load the version you used to create the conda env\r\nsource activate <em>myenv<\/em>                             # Activate your conda env\r\n\r\n# Install a package in your conda env to allow jupyter to use the conda env\r\npip install --isolated ipykernel\r\npip install --isolated ipywidgets\r\npython -m ipykernel install --user --name=<em>myenv<\/em> --display-name='Environment (<em>myenv<\/em>)'\r\nsource deactivate <em>myenv<\/em>\r\n\r\n# Return to the login node:\r\nexit\r\n<\/pre>\n<p>You can now submit a jupyter notebook job, using the &#8220;any&#8221; jupyter modulefile, which will NOT load an anaconda modulefile itself &#8211; hence you use your required version of anaconda<\/p>\n<pre># Submit a notebook job as normal from the login node:\r\n\r\nmodule load apps\/binapps\/anaconda3\/2024.10        # Load the version you used to create the conda env\r\nmodule load apps\/binapps\/jupyter-notebook\/any     # Uses the anaconda version you loaded\r\n\r\n# Now use the helper script to submit a job as described earlier. You DO NOT need to\r\n# activate your conda env, either on the login node or in the job. The above ipykernel\r\n# installation allows jupyter to find your conda envs.\r\njupyter-notebook-csf ...\r\n<\/pre>\n<p>Now when you connect to your notebook via a web-browser, you will be able to access your conda environment by selecting<\/p>\n<pre># In your web-browser, in the jupyter main screen, start a new notebook with access to your conda env:\r\nNew --&gt; Environment (<em>myenv<\/em>)\r\n<\/pre>\n<p>in the drop-down menu (at the top right-hand-side of the browser) to start a new python notebook &#8220;inside&#8221; your conda environment.<\/p>\n<h2>Further info<\/h2>\n<ul>\n<li><a href=\"http:\/\/jupyter.org\/\">Jupyter Notebook website<\/a><\/li>\n<\/ul>\n<h2>Updates<\/h2>\n<p>None.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. Please read carefully the instructions below when connecting a web-browser to your jupyter notebook on the CSF (slurm) &#8211; there are some extra steps needed that you would not normally do if you were running a jupyter notebook on your local desktop\/laptop (or the x2go virtual desktop if using that)&#8230; <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/applications\/jupyter-notebook-slurm\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"parent":86,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-9199","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/9199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/comments?post=9199"}],"version-history":[{"count":20,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/9199\/revisions"}],"predecessor-version":[{"id":12272,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/9199\/revisions\/12272"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/86"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/media?parent=9199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}