Jump toUpdate content
How to setup and configure Jupyter Notebook on a GPU Instance
Jupyter Notebook is a client-server application that allows to edit and run Notebook documents in a web browser.
The application allows to combine code, comments, multimedia contents, and visualizations in a single interactive document — called a notebook, which runs in a web browser.
The name Jupyter is an acronym which stands for the three languages it was initially designed for: JUlia, PYThon, and R, as the application was developed originally for data science needs. Nowadays Jupyter is the environment of choice for several use cases. Apart from research projects that involve visualizations of data or formulas it is used for documentation of processes with code, sharing of code or interactive visualizations.
Having evolved from its origins, today the application supports over 40 programming languages and is an open source project, based on the IPython Notebook project.
Log in to the Instance using SSH.
Update the apt repositories list and upgrade the packages already installed on the Instance:
apt update && apt upgrade -y
Reboot the Instance once the software has been upgraded:
Wait a few minutes and reconnect to the Instance:
Start the Jupyter Notebook application by running the following command:
jupyter notebook --no-browser --port=8888 --allow-root
- The flag
--no-browserprevents opening the notebook in a browser after startup.
- The flag
port=8888specifies the port on which the notebook listens. It is possible to change this value to another port number if required.
To connect to the Jupyter Notebook from a remote client, an SSH tunnel is required. SSH is available natively on Linux or MacOS computers.
Open a local terminal and run the following command on a client running on Linux or MacOS:
ssh -N -L localhost:7777:localhost:8888 root@gpu-instance-ip
The command above configures the port forwarding of the local port
7777to the port
8888on the GPU Instance. This allows access to the Jupyter Notebook with a web browser from the local computer.Tip:
Use the option
-fin the command above to move SSH into the background, so the local terminal remains usable.
Open a web browser and go to
http://localhost:7777. The Jupyter web interface should display:
To establish an SSH tunnel on a Windows computer, you need to have PuttY installed on the machine.
Open the PuttY application.
In the menu bar on the left, click Connection > SSH > Tunnels. Then add a new forwarded port:
- Fill in the Source port:
- Fill in the Destination:
- Click Add to add the configuration. Once done the forwarded port appears in the Forwarded ports list.
- Fill in the Source port:
Go back to the main window of PuttY and enter the connection details of the Instance, then click Open to log into it.
Keep the PuttY window open in the background and launch a web browser. Go to
http://localhost:7777to connect to the Jupyter Notebook:
- To access the Jupyter Notebook, an access token is required. It is displayed in the startup messages of the application:
- Copy the access token and open the URL
http://localhost:7777in a web browser:
Scroll down to the password section of the page and paste the token into the corresponding form. Then enter a safe password and click Log in and set new password to take the changes into effect:Tip:
In case an error 500 is displayed after setting the password, manually create a directory for Jupyter to store its configuration files:
You are now logged into Jupyter Notebook. The Dashboard displays :
You can now create a new or import an existing Jupyter Notebook by clicking on Upload or New:
Create a new Python 3 notebook by clicking on the corresponding line in the menu:
The Jupyter Editor displays. The first cell is already in place and uses the kernel (Python3) that was choosen when starting the notebook. Write your Python 3 code in the cell. To run the content of a cell click Play:
It is also possible to edit Markdown content in a Cell. To do so, change the status of a cell to Markdown by choosing it from the drop-down menu:
A running notebook is marked with a green icon. To suspend its execution, tick the corresponding box and click Shutdown:
For more information and advanced configuration of Jupyter Notebook, refer to the official documentation.