Accessing JupyterLab interface through Google Cloud Platform

A brief how-to guide

Alexander Weston, PhD
Towards Data Science

--

A monk at work. Image by Wikimedia Commons.

This article is part of a brief tutorial series on how to get set up on Google Cloud Platform for the first time. This article is on how to use the interactive web console.

For a general overview of GCP, please see my previous article.

One disclaimer — I’ve adapted this from documentation written for our summer interns because I thought it might be useful for a wider audience. We use a Cloud environment that was built by our own IT department with additional security appropriate for a large academic health institution. Therefore, several features of the platform may be modified or disabled.

If you also work for the Three Shields, you’ve come to the right article!

JupyterLab on GCP

The basic computing resource which is available on GCP is the “Deep-Learning Virtual Machine”, or “DLVM”. This is analogous to your personal computer, each person is assigned one (or more) DLVMs to develop and debug code.

There are many ways to access your Cloud DLVM, but one of the easiest ways to get started (and what seems to be the “default” option) is the interactive JupyterLab environment.

Accessing the Project

Firstly, you need to login to the appropriate Cloud project. If you are only using one project, you should be logged in automatically. Verify the project name is listed at the top of the screen, or under the “Project Info” card. If not, there’s a dropdown menu to select the appropriate project.

The Project Name is listed at the top of the GCP menu. Image by author.
If you are not logged into the correct Project, search and select it from the drop-down menu. Image by author.

Accessing the DLVM

Secondly, turn on the DVLM. Within the web interface, these are listed under the “Compute Engine” tab. If you are on a project with multiple users, everybody’s DLVMs will be listed.

If the DLVM is running, there will be a green check next to the name. You can start / stop DLVMs by opening up the “Options” menu and selecting the appropriate command. Note that you are charged whenever the DLVM is running, so please be considerate in stopping it when done for the day.

DLVMs for all users are displayed. A green check indicates the instance is running. To start/stop, click the appropriate option from the menu to the right. Image by author.

Opening JupyterLab

Accessing JupyterLab is done through the Vertex AI menu (don’t ask my why it’s not under the previous tab). Select Vertex AI from the upper right menu and go to Workbench.

Your DLVMs will again be listed under this menu. Select the Open JupyterLab button. This will open a new tab in your browser.

Under the VertexAI Workbench menu, launch JupyterLab from the appropriate DLVM. Image by author.

Jupyter Interface

JupyterLab will launch with the default editor. There’s many wonderful tutorials online for JupyterLab so I won’t belabor it here. Briefly, the main editing window is on the right, and an options menu is on the left which opens by default to a file browser.

Under the left-hand menu, you also have access to a listing of the Google Cloud Storage Bucket attached to the Project, a BigQuery menu, a manager for active Kernel instances, a GitHub interface, and an Extension manager. These are customizable and will vary depending on how your environment is configured.

Note that when you launch JupyterLab in this way, you will be logged in as user “jupyter” and the default home directory which is visible in the menu below is “/home/jupyter”. This is NOT the root user on the DLVM (on our machines, the root user is “ext_lastname_firstname_email_extension” which is the default when you SSH into the DLVM).

The main JupyterLab menu. File storage for the home directory /home/jupyter is shown in the left browser. Image by author.

JupyterLab is designed to work primarily with Jupyter Notebooks, which can be launched with the Python 3 card in the Launcher tab, or by clicking the blue Plus icon on the upper left menu. You have access to the Terminal in the Launcher as well. Another simple option I like to use is to edit a Python file in the built-in text editor which supports Python markdown and execute it in the terminal. It isn’t sophisticated, but it’s a great way to get started with just a few clicks, and frankly is not terribly different than editing in Sublime.

IPython Notebook interface in Google Cloud Platform’s JupyterLab. Image by author.
Text editing a Python script (left) and executing in the terminal (right) in Google Cloud Platform’s JupyterLab. Image by author.

Conclusion

There are many ways to get started using Google Cloud Platform, but the JupyterLab interface is possibly the quickest and easiest. Hopefully these instructions have been useful to you. Please leave a comment and I’ll be happy to answer any questions.

I’m sure readers would love to hear about your experience with the Platform, and any tricks or tips you can offer.

~AW

--

--