While we do not have an installation of Jupyterhub it is possible to set up a single Jupyter notebook running on the HPC system. This is a relatively straight forward process on Linux and Mac workstations/laptops as these systems have terminal programs built in. The Argon system has jupyter installed in the python stacks so the information here is currently only relevant Although Argon is unsuitable for providing a full JupyterHub installation, you can run a Jupyter Notebook on Argon and connect a web browser to it. This connection requires creating a network path, consisting of at least one SSH tunnel, between the system running your notebook and the system running the web browser. Thus to use a browser running on your local computer, one end of the tunnel needs to be on your computer.
The required SSH software and configuration are typically present on Linux and Mac workstations/notebooks by default, so the instructions on this page describing tunnel configuration should function there without additional configuration. A variation commonly used on Windows systems is also shown. The instructions for selecting a Python environment and running Jupyter are specific to the Argon HPC system.
There are two login nodes and normally you will wind up on one or the other based on a round robin scheme. For a jupyter notebook connection though you will have to connect to a specific login node. So, for Argon, pick one of the following login nodes to use:
- argon-login-1.hpc.uiowa.edu
- argon-login-2.hpc.uiowa.edu
The example below will use argon-login-1 but either one will work. First login to the HPC system via the selected login node.
No Format |
---|
ssh argon-login-1.hpc.uiowa.edu |
Once on the login node you must select the version of python that you want to use. Run the following command to see the available python environment modules.
No Format |
---|
module -tr avail ^python |
Load the selected python environment module.
No Format |
---|
module load python/2.7.13 |
Now, start a jupyter notebook, but without a browser. The goal is to be able to use the browser on your local machine.
No Format |
---|
jupyter notebook --no-browser |
The default port is 8888 but note that if there is anything else using that port, such as another jupyter notebook, then a different port will be used. The above command will automatically try a different port and will report that. The output will look something like the following:
...
Warning |
---|
Do not share the token with anyone. |
The important bit of information from the above for the next step is the port that was selected. That can be found immediately after localhost
. In the above the port number used is 8889
.
...
Warning |
---|
We strongly recommend running the Jupyter notebook sever on compute nodes using SGE scheduler since it could be harmful to other’s performance if you run it on login nodes. |
Generate script for running Jupyter Notebook:
Code Block $ mkdir $HOME/bin $ echo -e '#!/bin/bash\njupyter notebook --ip $(hostname -f) --no-browser --port=8080' > $HOME/bin/notebook.sh
In this step, you create a folder containing your private scripts including
notebook.sh
. In the second line, you will generate the script for running Jupyter Notebook. In this example, you set the port number to8080
, which can be replaced with any four-digit number.
Thenotebook.sh
will have the lines below:Code Block #!/bin/bash jupyter notebook --ip $(hostname -f) --no-browser --port=8080
You can reuse this script later as well and modify the port number if needed.
Convert the script to be executable
Code Block $ chmod +x $HOME/bin/notebook.sh
Load required modules
Code Block $ module load python $ module load py-jupyter
Warning | ||
---|---|---|
The default Python version is 2.7, so you should load the Python module to use a later version of Python. Check the available Python versions by:
|
Info | ||||
---|---|---|---|---|
You will need to load the required Python packages to use in the notebook. For example,
If you want to search the Python packages installed on Argon, type the command below:
Alternatively, you can activate a Python virtual environment or Conda virtual environment to build the list of packages you need. See Python for the detailed information. |
Start a Jupyter notebook on the compute nodes using the SGE scheduler
Code Block $ qrsh -q UI -N Jupyter -pe smp 2 -cwd $HOME/bin/notebook.sh
In this example, it requests
UI
queue with 2 slots (-pe smp 2
) and the name of the job isJupyter
. The-cwd
flag indicates that the Jupyter Notebook will access the current directory. You can modify the queue, number of slots, and the Job name.
If it successfully launches the Jupyter Notebook on the compute node, it will print out the logs like below:In this example, it runs on
argon-itf-bx47-36.hpc
node with forwarding the port to8080
. The token should be memorized to access the notebook in your local browser (the characters in the blue box above).
The port number is essentially a public address that anyone can use, even unintentionally (by typo, for example). The token is like a password; it only applies to the specific notebook running there (the one you launched just now), and it prints only in your specific terminal.
Warning |
---|
Do not share the token with anyone. |
Info |
---|
You can start the Jupyter Notebook in a screen or tmux session so that you can detach the terminal. See Screen and Tmux for more information. |
...
We will next set up
...
an SSH tunnel from a port on your local
...
machine to the remote machine. This will allow your browser to connect to the port on your local machine, and SSH will transfer the traffic between your system and the remote system to communicate with your notebook instance. By default, any computer should be able to refer to itself using the name "localhost", and this example follows that standard convention.
Ordinarily, all Web browsers try connecting to the standard Web port by default. But your notebook on the remote system is connected to its unique port there, so we'll specify a parameter to alter the destination port to match the port reported in the previous step.
The port on your system is independent of the port on the remote system running your notebook, but you may find it convenient to use the same port number.
...
Doing so will let you use the URL presented by
...
some versions of Jupyter Notebook without modification, such as in the example above.
Open another terminal session on your local
...
workstation or laptop and run the following command:
...
Code Block $ ssh -N -L localhost:8080:argon-itf-
...
bx47-36.hpc:8080 HawkID@argon.hpc.uiowa.edu
...
That will
...
configure a tunnel, from Local entry port
8080
on "localhost" (your system), toargon-itf-bx47-36.hpc
node, with destination port8080
(your notebook's port) through the login node. The destination compute node and the port should match what you set in the previous steps.
Info |
---|
Once you complete the login process with Duo authentication, it will display nothing. However, you should not turn off this terminal while you are running the Jupyter Notebook. If this terminal is turned off accidentally, you can simply re-access it and continue to use the Jupyter Notebook. |
Info |
---|
You can specify additional flags to the ssh command to further customize its behavior. These are beyond the scope of this demonstration. For example, using the |
...
them and manage them. |
Open a browser on your local computer and go to
http://localhost:8080
. This may require you to enter a token for secure access. You will need to copy the token (in step 3) and paste it.
Note | ||||
---|---|---|---|---|
Once you complete the job with the Jupyter Notebook, please stop the running of the notebook. You can do it by “Control-C” on the terminal that runs the notebook. You can check if it ends successfully by
where it will show the currently running notebook server if there is one. Additionally, you need to check if this job with the notebook is done by
Please do not keep the job alive when you are not practically using the Jupyter Notebook. |
Additional Tip
The process above should work on Linux and Mac systems without modification, but the process for Windows systems can vary.
Info |
---|
Windows users can use Putty instead of the "ssh" command to create the SSH tunnel. Just skip past this section if you aren't using Putty. |
In the left pane, expand "SSH" and select "Tunnels":
...
To create your new forwarded connection, enter the local port as the "Source" port, then the hostname and port number as the "Destination", localhost:8889 (in the example above it was 8080):
...
Click "Add" so that the new configuration is displayed as an entry listed in the "Forwarded Ports" box as shown here:
...
Click on the "Session" tab on the left side of the window:
...
Then open a normal SSH connection to your chosen login node:
...
The remaining steps and usage should be the same regardless of your tunnel.
After port forwarding is set up and running on your system, copy the URL reported when you launched your Jupyter Notebook, which resembles this:
http://localhost:8889/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Paste it into the browser of running on your local machine, modify it if your chosen version of Jupyter is reported in a different form, and hit enter. That should then open up establish a session connected to the jupyter notebook server. your Jupyter notebook server program, allowing you to interact with the notebook normally.
When you are finished using the notebook,
Control-C
in the local session with the ssh port forwarding to stop forwarding
...
Control-C
in the
...
shell session on the remote
...
node where
...
your jupyter notebook
...
is running
Info |
---|
Please remember that computationally intensive |
tasks should not be run on login nodes |
. Such tasks typically aren't well suited to interactive, Jupyter notebook-style computation in the first place, and should be formulated as non-interactive jobs which you then submit to Argon so that it can run them on compute node resources on your behalf. |