Although Argon is unsuitable for providing a full JupyterHub installation, you can run a Jupyter notebook 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 Jupyter are specific to the Argon HPC system.
For most Argon use, it's typical to connect to "argon.hpc.uiowa.edu", resulting in a login session on whichever of Argon's login nodes least recently served a new connection. However, to configure the tunnel for your jupyter notebook connection, you must ensure you consistently connect to the same login node in multiple steps. Therefore, for each connection you should use the "true" name one of Argon's login nodes instead of "argon.hpc.uiowa.edu":
- argon-login-1.hpc.uiowa.edu
- argon-login-2.hpc.uiowa.edu
- argon-login-3.hpc.uiowa.edu
- argon-login-4.hpc.uiowa.edu
The example here assumes shows how to connect using the browser on your local computer, and uses argon-login-1.hpc.uiowa.edu only as a specific example.
Note |
---|
For simplicity in illustrating tunnel setup, this particular example runs an instance of jupyter notebook on a login node. This arrangement is only suitable for visualizing data sets of modest size without additional processing. More generally, you should run jupyter notebook in a qlogin session on a compute node, in which case the simplest arrangement is to log into an Argon login node using FastX and use Firefox there. More elaborate arrangements are possible using more complex tunnel setup than illustrated here. |
First, connect to your chosen login node:
No Format |
---|
ssh argon-login-1.hpc.uiowa.edu |
In your session 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 (because you will use a browser on your local machine):
No Format |
---|
jupyter notebook --no-browser |
This makes launches a notebook instance, makes it available at a particular port on the system running, and prints the port in the terminal. It tries to use port 8888 first, but it if something else (such as another jupyter notebook) is already using a port, then it tries higher ports in sequence until it finds the next one available. The output will look something like the following:
Panel |
---|
[I 10:26:27.563 NotebookApp] The port 8888 is already in use, trying another port. |
For the next step, note the reported port, namely the number between "localhost:
" and "/
". In this example, it's 8889
.
Info |
---|
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,
|
Info |
---|
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), to
...
argon-
...
itf-bx47-
...
36.hpc
...
node, with destination port
...
8080
(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 |
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 as (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 notebookJupyter Notebook, which resembles this:
http://localhost:8889/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Paste it into the browser running on your local machine, modify it if your chosen version of jupyter Jupyter is reported in a different form, and hit enter. That should establish a session connected to your jupyter 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 forwardingControl-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. |