Table of contents:

Google Cloud datalab provides an interactive environment (via Jupyter notebooks) for analyzing data and designing machine learning models. Datalab is actually hosted on a Google Compute Engine with an attached disk capacity for storing the Jupyter notebooks.

In this piece, we’ll be launching Cloud Datalab for machine learning design using the gcloud command-line console.

Enable Google Compute Engine and Cloud Source Repositories APIs

On a new account, first, enable Google Compute API and then the Cloud Source Repositories API before launching datalab.

Figure 1: APIs & Services Dashboard

Enable Cloud Compute Engine API
Figure 2: Search for Compute Engine APIs
Figure 3: Enable Compute API
Figure 4: Google Compute Engine API Dashboard

Enable Cloud Source Repositories API
Figure 5: Search for Cloud Source Repositories APIs
Figure 6: Enable Cloud Source Repositories API
Figure 7: Google Cloud Source Repositories API Dashboard

Launch a Datalab Instance from gcloud

Working with the gcloud console allows us to interact with Google Cloud resources using the command-line directly from the browser. This tool is very convenient because the user need not install the Google Cloud SDK on the local machine. The gcloud feature allows users of low-end computers to do a lot of resource interaction directly within the cloud perimeter.

To launch a datalab instance,

  1. Open gcloud shell
  2. Create a datalab instance by running the command datalab create instance-name
  3. Accept all the defaults as the instance is provisioned
  4. Press Enter twice when asked to generate a passphrase.
  5. Click on the Web Preview at top-right of the gcloud window, click Change port and selet Port 8081, to start using Datalab.

Note: The instance-name must begin with a lowercase letter, and can have up to 63 lowercase letters, mixed with numbers and hyphens. The instance-name cannot end with a hyphen.

Figure 8: Open Cloud Shell

Figure 9: Create Datalab Instance

Figure 10: Select Zone

Figure 11: Type Y to generate SSH keys

Figure 12: Select Port 8081

Figure 13: Datalab Interface

Open a notebook

To open a new notebook. Click on New Notebook at the top-left hand corner of the instance page.

Figure 14: New Notebook

Shutting down/ Deleting the instance

To shut down the instance,

  1. Open the Cloud Compute Dashboard
  2. Click the check-box to select the instance.
  3. Click Stop to shut down the instance. Shutting down the instance prevents the user from incurring unnecessary cost when the instance is not in use.
  4. Click Delete to delete the instance and detach the disk allocated to the compute engine. Only use this action when completely done with all work on that instance. This action is irreversible.
Figure 15: Compute Dashboard

Figure 16: Shut-down Datalab Instance

Figure 17: Delete Datalab Instance