JupyterHub: Difference between revisions
No edit summary |
(Marked this version for translation) |
||
(47 intermediate revisions by 6 users not shown) | |||
Line 2: | Line 2: | ||
<translate> | <translate> | ||
<!--T:2--> | <!--T:2--> | ||
<i>JupyterHub is the best way to serve Jupyter Notebook for multiple users. It can be used in a class of students, a corporate data science group or scientific research group.</i> | |||
<ref>http://jupyterhub.readthedocs.io/en/latest/index.html</ref> | <ref>http://jupyterhub.readthedocs.io/en/latest/index.html</ref> | ||
Line 8: | Line 8: | ||
JupyterHub provides a preconfigured version of JupyterLab and/or Jupyter Notebook; for more configuration options, please check the [[Jupyter]] page. | JupyterHub provides a preconfigured version of JupyterLab and/or Jupyter Notebook; for more configuration options, please check the [[Jupyter]] page. | ||
{{Warning | |||
|title=Running notebooks | |||
|content=Jupyter Lab and notebooks are meant for '''short''' interactive tasks such as testing, debugging or quickly visualize data (few minutes). Running longer analysis must be done in an [[Running_jobs#Use_sbatch_to_submit_jobs|non-interactive job (sbatch)]]. | |||
See also [[JupyterHub#Running_notebooks_as_Python_scripts|how to run notebooks as python scripts below]]. | |||
}} | |||
= Alliance initiatives = <!--T:4--> | = Alliance initiatives = <!--T:4--> | ||
Line 21: | Line 26: | ||
! JupyterHub !! Comments | ! JupyterHub !! Comments | ||
|- | |- | ||
| | | <b>[https://jupyterhub.beluga.alliancecan.ca/ Béluga]</b> || Provides access to JupyterLab servers spawned through jobs on the [[Béluga/en|Béluga]] cluster. | ||
|- | |- | ||
| | | <b>[https://jupyterhub.cedar.computecanada.ca/ Cedar]</b> || Provides access to JupyterLab servers spawned through jobs on the [[Cedar]] cluster. | ||
|- | |- | ||
| | | <b>[https://jupyterhub.narval.alliancecan.ca/ Narval]</b> || Provides access to JupyterLab servers spawned through jobs on the [[Narval/en|Narval]] cluster. | ||
|- | |- | ||
| | | <b>[https://jupyter.scinet.utoronto.ca/ Niagara]</b> || This is a node which has been designated as a Jupyter Hub and it can run Jupyter Notebook sessions. To learn more, see the [https://docs.scinet.utoronto.ca/index.php/Jupyter_Hub SciNet JupyterHub wiki page]. | ||
|- | |- | ||
| | | <b>[https://jupyterhub.sharcnet.ca/ Graham]</b> || Provides access to JupyterLab servers spawned through jobs on the [[Graham]] cluster. | ||
|} | |} | ||
<!--T:18--> | <!--T:18--> | ||
<b><sup id="clusters_note">‡</sup> Note that the compute nodes running the Jupyter kernels do not have internet access</b>. This means that you can only transfer files from/to your own computer; you cannot download code or data from the internet (e.g. cannot do "git clone", cannot do "pip install" if the wheel is absent from our [[Available Python wheels|wheelhouse]]). You may also have problems if your code performs downloads or uploads (e.g. in machine learning where downloading data from the code is often done). | |||
== JupyterHub for universities and schools == <!--T:12--> | == JupyterHub for universities and schools == <!--T:12--> | ||
<!--T:6--> | <!--T:6--> | ||
* The [https://www.pims.math.ca Pacific Institute for the Mathematical Sciences] in collaboration with Alliance and [http://www.cybera.ca Cybera] offer cloud-based hubs to universities and schools. Each institution can have its own hub where users authenticate with their credentials from that institution. The hubs are hosted on | * The [https://www.pims.math.ca Pacific Institute for the Mathematical Sciences] in collaboration with the Alliance and [http://www.cybera.ca Cybera] offer cloud-based hubs to universities and schools. Each institution can have its own hub where users authenticate with their credentials from that institution. The hubs are hosted on Alliance [[Cloud|clouds]] and are essentially for training purposes. Institutions interested in obtaining their own hub can visit [http://syzygy.ca Syzygy]. | ||
= Server | = Server options = <!--T:13--> | ||
<!--T:14--> | <!--T:14--> | ||
[[File:JupyterHub_Server_Options.png|thumb| | [[File:JupyterHub_Server_Options.png|thumb|<i>Server Options</i> form on Béluga's JupyterHub]] | ||
Once logged in, depending on the configuration of JupyterHub, the user's | Once logged in, depending on the configuration of JupyterHub, the user's web browser is redirected to either | ||
a) a previously launched Jupyter server, | <b>a)</b> a previously launched Jupyter server, | ||
b) a new Jupyter server with default options, or | <b>b)</b> a new Jupyter server with default options, or | ||
c) a form that allows a user to set different options for their Jupyter server before pressing the | <b>c)</b> a form that allows a user to set different options for their Jupyter server before pressing the <i>Start</i> button. | ||
In all cases, it is | In all cases, it is equivalent to accessing requested resources via an [[Running_jobs#Interactive_jobs|interactive job]] on the corresponding cluster. | ||
<!--T:64--> | |||
<b>Important:</b> On each cluster, only one interactive job at a time gets a priority increase in order to start in a few seconds or minutes. That includes <code>salloc</code>, <code>srun</code> and JupyterHub jobs. If you already have another interactive job running on the cluster hosting JupyterHub, your new Jupyter session may never start before the time limit of 5 minutes. | |||
== Compute resources == <!--T:15--> | == Compute resources == <!--T:15--> | ||
<!--T:16--> | <!--T:16--> | ||
For example, | For example, <i>Server Options</i> available on [https://jupyterhub.beluga.computecanada.ca/ Béluga's JupyterHub] are: | ||
* | * <i>Account</i> to be used: any <code>def-*</code>, <code>rrg-*</code>, <code>rpp-*</code> or <code>ctb-*</code> account a user has access to | ||
* | * <i>Time (hours)</i> required for the session | ||
* | * <i>Number of (CPU) cores</i> that will be reserved on a single node | ||
* | * <i>Memory (MB)</i> limit for the entire session | ||
* (Optional) | * (Optional) <i>GPU configuration</i>: at least one GPU | ||
* | * <i>[[JupyterHub#User_Interface|User interface]]</i> (see below) | ||
== User | == User interface == <!--T:9--> | ||
<!--T:17--> | <!--T:17--> | ||
While JupyterHub allows each user to use one Jupyter server at a time on each hub, there can be multiple options under | While JupyterHub allows each user to use one Jupyter server at a time on each hub, there can be multiple options under <i>User interface</i>: | ||
* Jupyter Notebook (classic interface) | * Jupyter Notebook (classic interface): Even though it offers many functionalities, the community is moving towards [[JupyterHub#JupyterLab|JupyterLab]], which is a better platform that offers many more features. | ||
* | * <b>[[JupyterHub#JupyterLab|JupyterLab]]</b> (modern interface): This is the most recommended Jupyter user interface for interactive prototyping and data visualization. | ||
* Terminal (for a single terminal only) | * Terminal (for a single terminal only): It gives access to a terminal connected to a remote account, which is comparable to connecting to a server through an SSH connection. | ||
<!--T:10--> | <!--T:10--> | ||
Note: JupyterHub could have | Note: JupyterHub could also have been configured to force a specific user interface. This is usually done for special events. | ||
= JupyterLab = <!--T:19--> | = JupyterLab = <!--T:19--> | ||
Line 79: | Line 87: | ||
and you can launch Jupyter applications like a terminal, (Python 3) notebooks, RStudio and a Linux desktop. | and you can launch Jupyter applications like a terminal, (Python 3) notebooks, RStudio and a Linux desktop. | ||
== The JupyterLab | == The JupyterLab interface == <!--T:21--> | ||
<!--T:22--> | <!--T:22--> | ||
Line 88: | Line 96: | ||
<!--T:24--> | <!--T:24--> | ||
* In the | * In the <i>File</i> menu: | ||
** | ** <i>Hub Control Panel</i>: if you want to manually stop the JupyterLab server and the corresponding job on the cluster. This is useful when you want to start a new JupyterLab server with more or less resources. | ||
** | ** <i>Log Out</i>: the JupyterHub session will end, which will also stop the JupyterLab server and the corresponding job on the cluster. | ||
* Most other menu items are related to notebooks and Jupyter applications | * Most other menu items are related to notebooks and Jupyter applications. | ||
=== Tool selector on left === <!--T:25--> | === Tool selector on left === <!--T:25--> | ||
<!--T:26--> | <!--T:26--> | ||
* | * <i>File Browser</i> (folder icon): | ||
** This is where you can browse in your home, project and scratch spaces | ** This is where you can browse in your home, project and scratch spaces. | ||
** It is also possible to upload files | ** It is also possible to upload files. | ||
* | * <i>Running Terminals and Kernels</i> (stop icon): | ||
** To stop kernel sessions and terminal sessions | ** To stop kernel sessions and terminal sessions | ||
* | * <i>Commands</i> | ||
* | * <i>Property Inspector</i> | ||
* | * <i>Open Tabs</i>: | ||
** To navigate between application tabs | ** To navigate between application tabs. | ||
** To close application tabs | ** To close application tabs (the corresponding kernels remain active). | ||
[[File:JupyterLab_Softwares.png|thumb|Loaded modules and available modules]] | [[File:JupyterLab_Softwares.png|thumb|Loaded modules and available modules]] | ||
* | * <b><i>Software</i></b> (blue diamond sign): | ||
** Alliance modules can be loaded and unloaded in the JupyterLab session. Depending on the modules loaded, icons directing to the corresponding [[# | ** Alliance modules can be loaded and unloaded in the JupyterLab session. Depending on the modules loaded, icons directing to the corresponding [[#Prebuilt_applications|Jupyter applications]] will appear in the <i>Launcher</i> tab. | ||
** The search box can search for any [[Available software|available module]] and | ** The search box can search for any [[Available software|available module]] and show the result in the <i>Available Modules</i> subpanel. Note: Some modules are hidden until their dependency is loaded: we recommend that you first look for a specific module with <code>module spider module_name</code> from a terminal. | ||
** The next | ** The next subpanel is the list of <i>Loaded Modules</i> in the whole JupyterLab session. Note: While <code>python</code> and <code>ipython-kernel</code> modules are loaded by default, additional modules must be loaded before launching some other applications or notebooks. For example: <code>scipy-stack</code>. | ||
** The last | ** The last subpanel is the list of <i>Available modules</i>, similar to the output of <code>module avail</code>. By clicking on a module's name, detailed information about the module is displayed. By clicking on the <i>Load</i> link, the module will be loaded and added to the <i>Loaded Modules</i> list. | ||
=== | === Applications area on right === <!--T:27--> | ||
<!--T:28--> | <!--T:28--> | ||
* The | * The <i>Launcher</i> tab is open by default. | ||
** It contains all available [[# | ** It contains all available [[#Prebuilt_applications|Jupyter applications and notebooks]], depending on which modules are loaded | ||
=== Status bar at the bottom === <!--T:29--> | === Status bar at the bottom === <!--T:29--> | ||
<!--T:30--> | <!--T:30--> | ||
* By clicking on the icons, this brings you to the | * By clicking on the icons, this brings you to the <i>Running Terminals and Kernels</i> tool. | ||
== Prebuilt | == Prebuilt applications == <!--T:31--> | ||
<!--T:32--> | <!--T:32--> | ||
JupyterLab offers access to a terminal, an IDE (Desktop), a Python console and different options to create text and | JupyterLab offers access to a terminal, an IDE (Desktop), a Python console and different options to create text and markdown files. This section presents only the main supported Jupyter applications that work with our software stack. | ||
=== Command | === Command line interpreters === <!--T:33--> | ||
<!--T:34--> | <!--T:34--> | ||
Line 136: | Line 144: | ||
[[File:JupyterLab_Launcher_Terminal.png|thumb|Terminal launcher button]] | [[File:JupyterLab_Launcher_Terminal.png|thumb|Terminal launcher button]] | ||
==== Julia | ==== Julia console ==== <!--T:35--> | ||
<!--T:36--> | <!--T:36--> | ||
To enable the | To enable the <i>Julia 1.x</i> console launcher, an <code>ijulia-kernel</code> module needs to be loaded. When launched, a Julia interpreter is presented in a new JupyterLab tab. | ||
==== Python | ==== Python console ==== <!--T:37--> | ||
<!--T:38--> | <!--T:38--> | ||
The | The <i>Python 3.x</i> console launcher is available by default in a new JupyterLab session. When launched, a Python 3 interpreter is presented in a new JupyterLab tab. | ||
==== Terminal ==== <!--T:39--> | ==== Terminal ==== <!--T:39--> | ||
Line 150: | Line 158: | ||
<!--T:40--> | <!--T:40--> | ||
This application launcher will open a terminal in a new JupyterLab tab: | This application launcher will open a terminal in a new JupyterLab tab: | ||
* The terminal runs a (Bash) shell on the remote compute node without the need of an SSH connection | * The terminal runs a (Bash) shell on the remote compute node without the need of an SSH connection. | ||
** Gives access to the remote filesystems (<code>/home</code>, <code>/project</code>, <code>/scratch</code>) | ** Gives access to the remote filesystems (<code>/home</code>, <code>/project</code>, <code>/scratch</code>). | ||
** Allows running compute tasks | ** Allows running compute tasks. | ||
* The terminal allows copy-and-paste operations of text: | * The terminal allows copy-and-paste operations of text: | ||
** Copy operation: select the text, then press Ctrl+C | ** Copy operation: select the text, then press Ctrl+C. | ||
*** Note: | *** Note: Usually, Ctrl+C is used to send a SIGINT signal to a running process, or to cancel the current command. To get this behaviour in JupyterLab's terminal, click on the terminal to deselect any text before pressing Ctrl+C. | ||
** Paste operation: press Ctrl+V | ** Paste operation: press Ctrl+V. | ||
=== Available | === Available notebook kernels === <!--T:41--> | ||
==== Julia | ==== Julia notebook ==== <!--T:42--> | ||
<!--T:43--> | <!--T:43--> | ||
To enable the | To enable the <i>Julia 1.x</i> notebook launcher, an <code>ijulia-kernel</code> module needs to be loaded. When launched, a Julia notebook is presented in a new JupyterLab tab. | ||
==== Python | ==== Python notebook ==== <!--T:44--> | ||
<!--T:45--> | <!--T:45--> | ||
[[File:JupyterLab_Softwares_ScipyStack.png|thumb|Searching for scipy-stack modules]] | [[File:JupyterLab_Softwares_ScipyStack.png|thumb|Searching for scipy-stack modules]] | ||
If any of the following scientific Python packages is required by your notebook, before you open this notebook, you must load the <code>scipy-stack</code> module from the JupyterLab | If any of the following scientific Python packages is required by your notebook, before you open this notebook, you must load the <code>scipy-stack</code> module from the JupyterLab <i>Softwares</i> tool: | ||
* <code>ipython</code>, <code>ipython_genutils</code>, <code>ipykernel</code>, <code>ipyparallel</code> | * <code>ipython</code>, <code>ipython_genutils</code>, <code>ipykernel</code>, <code>ipyparallel</code> | ||
* <code>matplotlib</code> | * <code>matplotlib</code> | ||
Line 175: | Line 183: | ||
* <code>pandas</code> | * <code>pandas</code> | ||
* <code>scipy</code> | * <code>scipy</code> | ||
* Other notable packages | * Other notable packages are <code>Cycler</code>, <code>futures</code>, <code>jupyter_client</code>, <code>jupyter_core</code>, <code>mpmath</code>, <code>pathlib2</code>, <code>pexpect</code>, <code>pickleshare</code>, <code>ptyprocess</code>, <code>pyzmq</code>, <code>simplegeneric</code>, <code>sympy</code>, <code>tornado</code>, <code>traitlets</code>. | ||
* And many more (click on the <code>scipy-stack</code> module to see all | * And many more (click on the <code>scipy-stack</code> module to see all <i>Included extensions</i>). | ||
<!--T:46--> | <!--T:46--> | ||
Note: | Note: You may also install needed packages by running for example the following command inside a cell: <code>!pip install --no-index numpy</code>. | ||
* For some packages (like <code>plotly</code>, for example), you may need to restart the notebook's kernel before importing the package. | * For some packages (like <code>plotly</code>, for example), you may need to restart the notebook's kernel before importing the package. | ||
* The installation of packages in the default Python kernel environment is temporary to the lifetime of the JupyterLab session; you will have to reinstall these packages the next time you start a new JupyterLab session. For a persistent Python environment, you must configure a | * The installation of packages in the default Python kernel environment is temporary to the lifetime of the JupyterLab session; you will have to reinstall these packages the next time you start a new JupyterLab session. For a persistent Python environment, you must configure a <b>[[Advanced_Jupyter_configuration#Python_kernel|custom Python kernel]]</b>. | ||
<!--T:47--> | <!--T:47--> | ||
To open an existing Python notebook: | To open an existing Python notebook: | ||
* Go back to the | * Go back to the <i>File Browser</i>. | ||
* Browse to the location of the <code>*.ipynb</code> file | * Browse to the location of the <code>*.ipynb</code> file. | ||
* Double-click on the <code>*.ipynb</code> file | * Double-click on the <code>*.ipynb</code> file. | ||
** This will open the Python notebook in a new JupyterLab tab | ** This will open the Python notebook in a new JupyterLab tab. | ||
** An IPython kernel will start running in background for this notebook | ** An IPython kernel will start running in the background for this notebook. | ||
<!--T:48--> | <!--T:48--> | ||
To open a new Python notebook in the current | To open a new Python notebook in the current <i>File Browser</i> directory: | ||
* Click on the | * Click on the <i>Python 3.x</i> launcher under the <i>Notebook</i> section. | ||
** This will open a new Python 3 notebook in a new JupyterLab tab | ** This will open a new Python 3 notebook in a new JupyterLab tab. | ||
** A new IPython kernel will start running in background for this notebook | ** A new IPython kernel will start running in the background for this notebook. | ||
=== Other | === Other applications === <!--T:49--> | ||
==== OpenRefine ==== <!--T:50--> | ==== OpenRefine ==== <!--T:50--> | ||
Line 203: | Line 211: | ||
<!--T:51--> | <!--T:51--> | ||
[[File:JupyterLab_Launcher_OpenRefine.png|thumb|OpenRefine launcher button]] | [[File:JupyterLab_Launcher_OpenRefine.png|thumb|OpenRefine launcher button]] | ||
To enable the | To enable the <i>OpenRefine</i> application launcher, an <code>openrefine</code> module needs to be loaded. Depending on the software environment version, the latest version of OpenRefine should be loaded: | ||
* | * with <code>StdEnv/2023</code>, no OpenRefine module is available as of August 2024; please load <code>StdEnv/2020</code> first. | ||
* | * with <code>StdEnv/2020</code>, load module: <code>openrefine/3.4.1</code>. | ||
<!--T:52--> | <!--T:52--> | ||
This | This <i>OpenRefine</i> launcher will open or reopen an OpenRefine interface in a new web browser tab. | ||
* It is possible to reopen an active OpenRefine session after the | * It is possible to reopen an active OpenRefine session after the web browser tab was closed. | ||
* The OpenRefine session will end when the JupyterLab session | * The OpenRefine session will end when the JupyterLab session ends. | ||
==== RStudio ==== <!--T:53--> | ==== RStudio ==== <!--T:53--> | ||
Line 216: | Line 224: | ||
<!--T:54--> | <!--T:54--> | ||
[[File:JupyterLab_Launcher_RStudio.png|thumb|RStudio launcher button]] | [[File:JupyterLab_Launcher_RStudio.png|thumb|RStudio launcher button]] | ||
To enable the | To enable the <i>RStudio</i> application launcher, load the module: <code>rstudio-server/4.3</code> | ||
<!--T:56--> | <!--T:56--> | ||
This | This <i>RStudio</i> launcher will open or reopen an RStudio interface in a new web browser tab. | ||
* It is possible to reopen an active RStudio session after the | * It is possible to reopen an active RStudio session after the web browser tab was closed. | ||
* The RStudio session will end when the JupyterLab session | * The RStudio session will end when the JupyterLab session ends. | ||
==== VS Code ==== <!--T:57--> | ==== VS Code ==== <!--T:57--> | ||
Line 232: | Line 235: | ||
<!--T:58--> | <!--T:58--> | ||
[[File:JupyterLab_Launcher_VSCode.png|thumb|VS Code launcher button]] | [[File:JupyterLab_Launcher_VSCode.png|thumb|VS Code launcher button]] | ||
To enable the | To enable the <i>VS Code</i> (Visual Studio Code) application launcher, a <code>code-server</code> module needs to be loaded. Depending on the software environment version, the latest version of VS Code should be loaded: | ||
* | * with <code>StdEnv/2023</code>, there is no <code>code-server</code> module as of August 2024. Users wishing to debug on a compute node through their local VS Code should [[Visual_Studio_Code#Connection_to_a_compute_node|follow instructions here]]. | ||
* | * with <code>StdEnv/2020</code>, load module: <code>code-server/3.12.0</code>. | ||
<!--T:59--> | <!--T:59--> | ||
This | This <i>VS Code</i> launcher will open or reopen the VS Code interface in a new web browser tab. | ||
* For a new session, the | * For a new session, the <i>VS Code</i> session can take up to 3 minutes to complete its startup. | ||
* It is possible to reopen an active VS Code session after the | * It is possible to reopen an active VS Code session after the web browser tab was closed. | ||
* The VS Code session will end when the JupyterLab session | * The VS Code session will end when the JupyterLab session ends. | ||
==== Desktop ==== <!--T:60--> | ==== Desktop ==== <!--T:60--> | ||
Line 246: | Line 249: | ||
<!--T:61--> | <!--T:61--> | ||
[[File:JupyterLab_Launcher_Desktop.png|thumb|Desktop launcher button]] | [[File:JupyterLab_Launcher_Desktop.png|thumb|Desktop launcher button]] | ||
This | This <i>Desktop</i> launcher will open or reopen a remote Linux desktop interface in a new web browser tab: | ||
* This is equivalent to running a [[VNC#Compute_Nodes|VNC server on a compute node]], then creating an [[SSH_tunnelling|SSH tunnel]] and finally using a [[VNC#Setup|VNC client]], but you need nothing of all this with JupyterLab! | * This is equivalent to running a [[VNC#Compute_Nodes|VNC server on a compute node]], then creating an [[SSH_tunnelling|SSH tunnel]] and finally using a [[VNC#Setup|VNC client]], but you need nothing of all this with JupyterLab! | ||
* It is possible to reopen an active desktop session after the | * It is possible to reopen an active desktop session after the web browser tab was closed. | ||
* The desktop session will end when the JupyterLab session | * The desktop session will end when the JupyterLab session ends. | ||
== Running notebooks as Python scripts == <!--T:65--> | |||
<!--T:66--> | |||
1. From the console, or in a new notebook cell, install <tt>nbconvert</tt> : | |||
<syntaxhighlight lang="bash">!pip install --no-index nbconvert</syntaxhighlight> | |||
<!--T:67--> | |||
2. Convert your notebooks to Python scripts | |||
<syntaxhighlight lang="bash">!jupyter nbconvert --to python my-current-notebook.ipynb</syntaxhighlight> | |||
<!--T:68--> | |||
3. Create your [[Running_jobs#Use_sbatch_to_submit_jobs|non-interactive submission script]], and submit it. | |||
<!--T:69--> | |||
In your submission script, run your converted notebook with: | |||
<syntaxhighlight lang="bash">python my-current-notebook.py</syntaxhighlight> | |||
<!--T:70--> | |||
And submit your non-interactive job: | |||
{{Command | |||
|sbatch my-submit.sh | |||
}} | |||
= Possible error messages = <!--T:62--> | = Possible error messages = <!--T:62--> | ||
Line 255: | Line 281: | ||
<!--T:63--> | <!--T:63--> | ||
Most JupyterHub errors are caused by the underlying job scheduler which is either unresponsive or not able to find appropriate resources for your session. For example: | Most JupyterHub errors are caused by the underlying job scheduler which is either unresponsive or not able to find appropriate resources for your session. For example: | ||
* | |||
** Just like any interactive job on any cluster, a longer requested time can cause a longer wait time in queue | <!--T:71--> | ||
** There may be no available | <b>Spawn failed: Timeout</b> | ||
[[File:JupyterHub Spawn failed Timeout.png|thumb|upright=1.1|JupyterHub - Spawn failed: Timeout]] | |||
* When starting a new session, JupyterHub automatically submits on your behalf a new [[Running_jobs#Interactive_jobs|interactive job]] to the cluster. If the job does not start within five minutes, a "Timeout" error message is raised and the session is cancelled. | |||
** Just like any interactive job on any cluster, a longer requested time can cause a longer wait time in the queue. Requesting a GPU or too many CPU cores can also cause a longer wait time. Make sure to request only the resources you need for your session. | |||
** If you already have another interactive job on the same cluster, your Jupyter session will be waiting along with other regular batch jobs in the queue. If possible, stop or cancel any other interactive job before using JupyterHub. | |||
** There may be just no resource available at the moment. Check the [https://status.alliancecan.ca/ status page] for any issue and try again later. | |||
= References = <!--T:7--> | = References = <!--T:7--> | ||
</translate> | </translate> |
Latest revision as of 22:25, 18 September 2024
JupyterHub is the best way to serve Jupyter Notebook for multiple users. It can be used in a class of students, a corporate data science group or scientific research group. [1]
JupyterHub provides a preconfigured version of JupyterLab and/or Jupyter Notebook; for more configuration options, please check the Jupyter page.
Jupyter Lab and notebooks are meant for short interactive tasks such as testing, debugging or quickly visualize data (few minutes). Running longer analysis must be done in an non-interactive job (sbatch). See also how to run notebooks as python scripts below.
Alliance initiatives
Some regional initiatives offer access to computing resources through JupyterHub.
JupyterHub on clusters
On the following clusters‡, use your Alliance username and password to connect to JupyterHub:
JupyterHub | Comments |
---|---|
Béluga | Provides access to JupyterLab servers spawned through jobs on the Béluga cluster. |
Cedar | Provides access to JupyterLab servers spawned through jobs on the Cedar cluster. |
Narval | Provides access to JupyterLab servers spawned through jobs on the Narval cluster. |
Niagara | This is a node which has been designated as a Jupyter Hub and it can run Jupyter Notebook sessions. To learn more, see the SciNet JupyterHub wiki page. |
Graham | Provides access to JupyterLab servers spawned through jobs on the Graham cluster. |
‡ Note that the compute nodes running the Jupyter kernels do not have internet access. This means that you can only transfer files from/to your own computer; you cannot download code or data from the internet (e.g. cannot do "git clone", cannot do "pip install" if the wheel is absent from our wheelhouse). You may also have problems if your code performs downloads or uploads (e.g. in machine learning where downloading data from the code is often done).
JupyterHub for universities and schools
- The Pacific Institute for the Mathematical Sciences in collaboration with the Alliance and Cybera offer cloud-based hubs to universities and schools. Each institution can have its own hub where users authenticate with their credentials from that institution. The hubs are hosted on Alliance clouds and are essentially for training purposes. Institutions interested in obtaining their own hub can visit Syzygy.
Server options
Once logged in, depending on the configuration of JupyterHub, the user's web browser is redirected to either a) a previously launched Jupyter server, b) a new Jupyter server with default options, or c) a form that allows a user to set different options for their Jupyter server before pressing the Start button. In all cases, it is equivalent to accessing requested resources via an interactive job on the corresponding cluster.
Important: On each cluster, only one interactive job at a time gets a priority increase in order to start in a few seconds or minutes. That includes salloc
, srun
and JupyterHub jobs. If you already have another interactive job running on the cluster hosting JupyterHub, your new Jupyter session may never start before the time limit of 5 minutes.
Compute resources
For example, Server Options available on Béluga's JupyterHub are:
- Account to be used: any
def-*
,rrg-*
,rpp-*
orctb-*
account a user has access to - Time (hours) required for the session
- Number of (CPU) cores that will be reserved on a single node
- Memory (MB) limit for the entire session
- (Optional) GPU configuration: at least one GPU
- User interface (see below)
User interface
While JupyterHub allows each user to use one Jupyter server at a time on each hub, there can be multiple options under User interface:
- Jupyter Notebook (classic interface): Even though it offers many functionalities, the community is moving towards JupyterLab, which is a better platform that offers many more features.
- JupyterLab (modern interface): This is the most recommended Jupyter user interface for interactive prototyping and data visualization.
- Terminal (for a single terminal only): It gives access to a terminal connected to a remote account, which is comparable to connecting to a server through an SSH connection.
Note: JupyterHub could also have been configured to force a specific user interface. This is usually done for special events.
JupyterLab
JupyterLab is now the recommended general-purpose user interface to use on a JupyterHub. From a JupyterLab server, you can manage your remote files and folders, and you can launch Jupyter applications like a terminal, (Python 3) notebooks, RStudio and a Linux desktop.
The JupyterLab interface
When JupyterLab is ready to be used, the interface has multiple panels.
Menu bar on top
- In the File menu:
- Hub Control Panel: if you want to manually stop the JupyterLab server and the corresponding job on the cluster. This is useful when you want to start a new JupyterLab server with more or less resources.
- Log Out: the JupyterHub session will end, which will also stop the JupyterLab server and the corresponding job on the cluster.
- Most other menu items are related to notebooks and Jupyter applications.
Tool selector on left
- File Browser (folder icon):
- This is where you can browse in your home, project and scratch spaces.
- It is also possible to upload files.
- Running Terminals and Kernels (stop icon):
- To stop kernel sessions and terminal sessions
- Commands
- Property Inspector
- Open Tabs:
- To navigate between application tabs.
- To close application tabs (the corresponding kernels remain active).
- Software (blue diamond sign):
- Alliance modules can be loaded and unloaded in the JupyterLab session. Depending on the modules loaded, icons directing to the corresponding Jupyter applications will appear in the Launcher tab.
- The search box can search for any available module and show the result in the Available Modules subpanel. Note: Some modules are hidden until their dependency is loaded: we recommend that you first look for a specific module with
module spider module_name
from a terminal. - The next subpanel is the list of Loaded Modules in the whole JupyterLab session. Note: While
python
andipython-kernel
modules are loaded by default, additional modules must be loaded before launching some other applications or notebooks. For example:scipy-stack
. - The last subpanel is the list of Available modules, similar to the output of
module avail
. By clicking on a module's name, detailed information about the module is displayed. By clicking on the Load link, the module will be loaded and added to the Loaded Modules list.
Applications area on right
- The Launcher tab is open by default.
- It contains all available Jupyter applications and notebooks, depending on which modules are loaded
Status bar at the bottom
- By clicking on the icons, this brings you to the Running Terminals and Kernels tool.
Prebuilt applications
JupyterLab offers access to a terminal, an IDE (Desktop), a Python console and different options to create text and markdown files. This section presents only the main supported Jupyter applications that work with our software stack.
Command line interpreters
Julia console
To enable the Julia 1.x console launcher, an ijulia-kernel
module needs to be loaded. When launched, a Julia interpreter is presented in a new JupyterLab tab.
Python console
The Python 3.x console launcher is available by default in a new JupyterLab session. When launched, a Python 3 interpreter is presented in a new JupyterLab tab.
Terminal
This application launcher will open a terminal in a new JupyterLab tab:
- The terminal runs a (Bash) shell on the remote compute node without the need of an SSH connection.
- Gives access to the remote filesystems (
/home
,/project
,/scratch
). - Allows running compute tasks.
- Gives access to the remote filesystems (
- The terminal allows copy-and-paste operations of text:
- Copy operation: select the text, then press Ctrl+C.
- Note: Usually, Ctrl+C is used to send a SIGINT signal to a running process, or to cancel the current command. To get this behaviour in JupyterLab's terminal, click on the terminal to deselect any text before pressing Ctrl+C.
- Paste operation: press Ctrl+V.
- Copy operation: select the text, then press Ctrl+C.
Available notebook kernels
Julia notebook
To enable the Julia 1.x notebook launcher, an ijulia-kernel
module needs to be loaded. When launched, a Julia notebook is presented in a new JupyterLab tab.
Python notebook
If any of the following scientific Python packages is required by your notebook, before you open this notebook, you must load the scipy-stack
module from the JupyterLab Softwares tool:
ipython
,ipython_genutils
,ipykernel
,ipyparallel
matplotlib
numpy
pandas
scipy
- Other notable packages are
Cycler
,futures
,jupyter_client
,jupyter_core
,mpmath
,pathlib2
,pexpect
,pickleshare
,ptyprocess
,pyzmq
,simplegeneric
,sympy
,tornado
,traitlets
. - And many more (click on the
scipy-stack
module to see all Included extensions).
Note: You may also install needed packages by running for example the following command inside a cell: !pip install --no-index numpy
.
- For some packages (like
plotly
, for example), you may need to restart the notebook's kernel before importing the package. - The installation of packages in the default Python kernel environment is temporary to the lifetime of the JupyterLab session; you will have to reinstall these packages the next time you start a new JupyterLab session. For a persistent Python environment, you must configure a custom Python kernel.
To open an existing Python notebook:
- Go back to the File Browser.
- Browse to the location of the
*.ipynb
file. - Double-click on the
*.ipynb
file.- This will open the Python notebook in a new JupyterLab tab.
- An IPython kernel will start running in the background for this notebook.
To open a new Python notebook in the current File Browser directory:
- Click on the Python 3.x launcher under the Notebook section.
- This will open a new Python 3 notebook in a new JupyterLab tab.
- A new IPython kernel will start running in the background for this notebook.
Other applications
OpenRefine
To enable the OpenRefine application launcher, an openrefine
module needs to be loaded. Depending on the software environment version, the latest version of OpenRefine should be loaded:
- with
StdEnv/2023
, no OpenRefine module is available as of August 2024; please loadStdEnv/2020
first. - with
StdEnv/2020
, load module:openrefine/3.4.1
.
This OpenRefine launcher will open or reopen an OpenRefine interface in a new web browser tab.
- It is possible to reopen an active OpenRefine session after the web browser tab was closed.
- The OpenRefine session will end when the JupyterLab session ends.
RStudio
To enable the RStudio application launcher, load the module: rstudio-server/4.3
This RStudio launcher will open or reopen an RStudio interface in a new web browser tab.
- It is possible to reopen an active RStudio session after the web browser tab was closed.
- The RStudio session will end when the JupyterLab session ends.
VS Code
To enable the VS Code (Visual Studio Code) application launcher, a code-server
module needs to be loaded. Depending on the software environment version, the latest version of VS Code should be loaded:
- with
StdEnv/2023
, there is nocode-server
module as of August 2024. Users wishing to debug on a compute node through their local VS Code should follow instructions here. - with
StdEnv/2020
, load module:code-server/3.12.0
.
This VS Code launcher will open or reopen the VS Code interface in a new web browser tab.
- For a new session, the VS Code session can take up to 3 minutes to complete its startup.
- It is possible to reopen an active VS Code session after the web browser tab was closed.
- The VS Code session will end when the JupyterLab session ends.
Desktop
This Desktop launcher will open or reopen a remote Linux desktop interface in a new web browser tab:
- This is equivalent to running a VNC server on a compute node, then creating an SSH tunnel and finally using a VNC client, but you need nothing of all this with JupyterLab!
- It is possible to reopen an active desktop session after the web browser tab was closed.
- The desktop session will end when the JupyterLab session ends.
Running notebooks as Python scripts
1. From the console, or in a new notebook cell, install nbconvert :
!pip install --no-index nbconvert
2. Convert your notebooks to Python scripts
!jupyter nbconvert --to python my-current-notebook.ipynb
3. Create your non-interactive submission script, and submit it.
In your submission script, run your converted notebook with:
python my-current-notebook.py
And submit your non-interactive job:
[name@server ~]$ sbatch my-submit.sh
Possible error messages
Most JupyterHub errors are caused by the underlying job scheduler which is either unresponsive or not able to find appropriate resources for your session. For example:
Spawn failed: Timeout
- When starting a new session, JupyterHub automatically submits on your behalf a new interactive job to the cluster. If the job does not start within five minutes, a "Timeout" error message is raised and the session is cancelled.
- Just like any interactive job on any cluster, a longer requested time can cause a longer wait time in the queue. Requesting a GPU or too many CPU cores can also cause a longer wait time. Make sure to request only the resources you need for your session.
- If you already have another interactive job on the same cluster, your Jupyter session will be waiting along with other regular batch jobs in the queue. If possible, stop or cancel any other interactive job before using JupyterHub.
- There may be just no resource available at the moment. Check the status page for any issue and try again later.