{"id":909,"date":"2019-03-22T17:43:46","date_gmt":"2019-03-22T17:43:46","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/icsf\/?page_id=909"},"modified":"2024-11-27T14:02:13","modified_gmt":"2024-11-27T14:02:13","slug":"jupyter-notebook-2","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/software\/applications\/jupyter-notebook-2\/","title":{"rendered":"Jupyter Notebook"},"content":{"rendered":"<div class=\"hint\">This app replaces iPython notebook.<br \/>\nPlease use our Linux Virtual Desktop (nyx5,6,7) to access a running notebook through a web-browser.<\/div>\n<h2>Overview<\/h2>\n<p><a href=\"https:\/\/jupyter.org\/\">Jupyter Notebook<\/a> is a web-based interactive computational environment where you can combine code execution, text, mathematics, plots and rich media into a single document. We execute python commands and view the results in a web browser. The python commands execute remotely on the iCSF (where more memory and compute-power exists).<\/p>\n<p>Jupyter Notebook version 5.0.0 is installed on the iCSF as part of the <a href=\"\/icsf\/software\/applications\/anaconda-python\">Anaconda3 4.2.0<\/a> package. This runs Python 3.5.2.<\/p>\n<h2>Restrictions on use<\/h2>\n<p>There are no restrictions accessing this software. However you must have an account on the <code>nyx5<\/code> \/ <code>nyx6<\/code> \/ <code>nyx7<\/code> virtual desktop server from which you then access the iCSF. Please see <a href=\"http:\/\/ri.itservices.manchester.ac.uk\/virtual-desktop-service-x2go\/\">X2GO virtual desktop<\/a> for details. To request an account on nyx5,6,7 please email <a href=\"m&#97;&#105;&#x6c;&#x74;&#x6f;:&#105;&#116;&#x73;&#x2d;&#x72;i-&#116;&#x65;&#x61;&#x6d;&#64;m&#97;&#110;&#x63;&#x68;&#x65;s&#116;&#101;&#x72;&#x2e;&#x61;c&#46;&#117;&#x6b;\">it&#115;&#45;&#x72;&#x69;&#x2d;&#x74;ea&#109;&#64;&#x6d;&#x61;&#x6e;&#x63;he&#115;&#116;&#101;&#x72;&#x2e;&#x61;&#x63;&#46;u&#107;<\/a> (we will set up your account on all of the nyx servers).<\/p>\n<h2>Set up procedure<\/h2>\n<p>The Jupyter Notebook software runs on one of the iCSF compute nodes (Aug 2024: All nodes are now 2TB nodes.) However, we <em>do not<\/em> manually log in to the iCSF and run the Jupyter Notebook software directly. Instead we run a script <em>on the nyx5\/nyx6\/nyx7<\/em> virtual desktop to manage the whole business of connecting to the iCSF and running the Jupyter Notebook software.<\/p>\n<p>Hence you must first log in to the nyx5 or nyx6 or nyx7 <a href=\"http:\/\/ri.itservices.manchester.ac.uk\/virtual-desktop-service\/x2go\/\">virtual desktop service<\/a> using the <em>x2goclient<\/em> software. See links for details.<\/p>\n<h2>Running the application<\/h2>\n<p>The following instructions assume you are logged in to the <em>nyx5<\/em> virtual desktop (we use nyx5 in this example but you can also use nyx6 or nyx7).<\/p>\n<h3>Launching the Jupyter Notebook on to the iCSF<\/h3>\n<p>Note: we use nyx7 in this example but you can also use nyx6 or nyx5.<\/p>\n<ol>\n<li><strong>On nyx7<\/strong>, open a shell window (e.g., using menu: <em>Applications -&gt; System Tools -&gt; Terminal<\/em>)<\/li>\n<li>In the terminal, run:\n<pre># <strong>You run this command on nyx7 (or nyx6, or nyx5), <em>not<\/em> the iCSF.<\/strong>\r\n# It will login to the iCSF and run a jupyter notebook.\r\njupyter-notebook-icsf\r\n<\/pre>\n<\/li>\n<li>Enter your iCSF password when prompted:\n<pre>Connecting to the iCSF to start a Jupyter Notebook...\r\n<em>username<\/em>@incline256's password:  <strong>type your UoM IT password<\/strong>\r\n                                    (no characters will be displayed while you type)\r\n<\/pre>\n<\/li>\n<li>Make a note of the URL address given to you &#8211; e.g.:\n<pre>http:\/\/localhost:7777\/?token=<em>long-string-of-characters<\/em><\/pre>\n<p>(the number <code>7777<\/code> may differ).<\/li>\n<\/ol>\n<p>This will log you in to the iCSF (incline) and start the Jupyter Notebook server. Hence you will be asked for your iCSF password. Enter it when prompted.<\/p>\n<p>For example, the complete output is:<\/p>\n<pre>[mabcxyz1@nyx7 ~]$ jupyter-notebook-icsf\r\n\r\n===================== Use the URL given here ====================\r\n\r\n 1. Enter your iCSF password when prompted below\r\n 2. On nyx7 please start firefox and browse to:\r\n\r\n           http:\/\/localhost:7777\/?token=&lt;long string of characters&gt;\r\n\r\n    (see below for the 'token' string to add to the above address)\r\n\r\nConnecting to the iCSF to start a Jupyter Notebook...\r\nmabcxyz1@incline256's password: <strong>&lt;enter your iCSF password&gt;<\/strong>\r\n<\/pre>\n<p>You will have been automatically logged in to the iCSF (on to one of the backend 2TB nodes). Notice the URL advertised to you:<\/p>\n<pre>http:\/\/localhost:<strong>7777\/?token=<em>long-string-of-characters<\/em><\/strong><\/pre>\n<p>The <code>7777<\/code> port number may be different in your output. You should <strong>make a note<\/strong> of the URL, particularly the port number and long string of random characters (which acts like a random password that only you can see &#8211; it prevents other people from access your notebook on the iCSF). We will access this URL in a web browser shortly.<\/p>\n<p>You will see some output from the Jupyter Notebook server and then the message:<\/p>\n<pre>======= ** IMPORTANT - YOU MUST DO THIS WHEN FINISHED WITH Jupyter ** =======\r\n Please use CTRL-C in this window to terminate Jupyter Notebook on incline21\r\n (PID 102924) ...\r\n<\/pre>\n<p>We will use this when shutting down the server at the end of our session (see below).<\/p>\n<h3>View the Jupyter Notebook in a Web Browser on nyx7<\/h3>\n<p>On the <em>nyx7<\/em> virtual desktop:<\/p>\n<ol class=\"gaplist\">\n<li>Start <code>firefox<\/code> (e.g., using menu: <em>Applications -&gt; Internet -&gt; Firefox ESR<\/em>)<\/li>\n<li>Now enter the following address in the browser address bar at the top:\n<pre>http:\/\/localhost:7777\/?token=<em>long-string-of-characters<\/em><\/pre>\n<p>where <code>7777\/?token=<em>long-string-of-characters<\/em><\/code> and is the number and string reported to you earlier when you ran <code>jupyter-notebook-icsf<\/code> in the command window. Your numbers may be different!<\/li>\n<\/ol>\n<p>You should now see the Jupyter Notebook <em>dashboard<\/em> in your web browser. This has connected to the iCSF backend node running the Jupyter Notebook.<\/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 class=\"gaplist\">\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=\"http:\/\/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\" \/><\/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=\"http:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-content\/uploads\/jupyter-example-notebook-mandelbrot-result.png\" alt=\"Mandelbrot notebook result\" width=\"512\" height=\"297\" \/><\/a><\/li>\n<\/ol>\n<h3>Stopping the Remote Notebook Server<\/h3>\n<p>As mentioned above, when you have finished using the Jupyter Notebook on the iCSF you must close it down. Otherwise server processes may be left running on the iCSF backend nodes.<\/p>\n<ol class=\"gaplist\">\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<\/li>\n<li>Now type <code>CTRL-C<\/code> in the shell window that displayed the URL and message about pressing <code>Ctrl+C<\/code>. It will report that it has shut down the server. You will be automatically logged out of the iCSF, leaving the shell window back at the <em>nyx7<\/em> prompt:\n<pre>======= ** IMPORTANT - YOU MUST DO THIS WHEN FINISHED WITH Jupyter ** =======\r\n Please use CTRL-C in this window to terminate Jupyter Notebook on incline21\r\n (PID 102924) ...\r\n\r\n....output while you were using the notebook in the web-browser....\r\n\r\n^C     <strong>&lt;-- here we pressed CTRL-C<\/strong>\r\n[C 18:03:17.113 NotebookApp] received signal 15, stopping\r\n[I 18:03:17.198 NotebookApp] Shutting down kernels\r\n[I 18:03:17.800 NotebookApp] Kernel shutdown: 25521668-a97f-444b-8cac-e3718c8213c8\r\n\r\nTerminated Jupyter Notebook on incline21 (PID 102924).\r\nIf the command-prompt does not appear, press Ctrl+C again.\r\n\r\nConnection to incline closed.\r\nmabcxyz1@nyx7:~$ \r\n<\/pre>\n<\/li>\n<li>That&#8217;s it, we&#8217;re back on nyx7 and the Jupyter Notebook server we were running on the iCSF has finished.<\/li>\n<\/ol>\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>This app replaces iPython notebook. Please use our Linux Virtual Desktop (nyx5,6,7) to access a running notebook through a web-browser. Overview Jupyter Notebook is a web-based interactive computational environment where you can combine code execution, text, mathematics, plots and rich media into a single document. We execute python commands and view the results in a web browser. The python commands execute remotely on the iCSF (where more memory and compute-power exists). Jupyter Notebook version 5.0.0.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/software\/applications\/jupyter-notebook-2\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":43,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-909","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/comments?post=909"}],"version-history":[{"count":20,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/909\/revisions"}],"predecessor-version":[{"id":1476,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/909\/revisions\/1476"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/pages\/43"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/icsf\/wp-json\/wp\/v2\/media?parent=909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}