Using JupyterLab from Google Cloud

Thomas Capelle
2 min readJan 4, 2019

--

This is just a short tutorial on how to use Jupyter on Google Cloud from within your web browser, without a ssh connection.

This is the trick, click here and you will see the virtual machine browser at localhost:8080

I have been using fast.ai library for some kaggle competitions lately, and I recently found that you could connect to the Compute Engine instance from within the browser and have jupyterlab forwarded to your computer without any setup.

Let’s asume you already have a virtual machine setup and running (if not, you can check here and here). Get the gcloud command.

get the gcloud command

It should be something like this:

gcloud compute — project “PROJECT-NAME” ssh — zone “ZONE” “my-fastai-instance” 

The trick is to connect with the Cloud Shell console, to do this, from the right corner of your Google Console page, click on the “Activate Shell” icon.

Now from the console, connect to the instance (using the gcloud command shown before) but append the port forwarding:

gcloud compute — project “PROJECT-NAME” ssh — zone “ZONE” “my-fastai-instance” -- -L 8080:localhost:8080

This will forward the port 8080 in the VM instance to this cloud shell.

Once connected, click the web preview button and select “Preview on port 8080”

You should see JupyterLab launching. Enjoy!

  • To be precise, I am using a VM created from the Pytorch V1.0 and fastai image, so Jupyter is already running when I launch the machine. This image is preconfigured with HTTP traffic allowed and has a user called jupyter that has jupyter running.

--

--

Thomas Capelle

Data Scientist in the Alps region of France. Solar Energy, Urban Dynamics and Python.