Cloud Intelligence™Cloud Intelligence™

Cloud Intelligence™

Automatically Shut Down Vertex AI User-Managed Notebooks

This page is also available in Deutsch, Español, Français, Italiano, 日本語, and Português.

Sascha Heyer
By Sascha Heyer
May 10, 20232 min read

Vertex AI provides two types of notebooks: Google-managed and user-managed.

Google-managed notebooks automatically shut down after a period of inactivity, which helps save costs and prevent billing surprises. However, there isn’t an integrated method for automatically shutting down user-managed notebooks — until now.

Thanks to Jose Brache, you can now add similar functionality to user-managed notebooks in just a few simple steps.

Note that there is a difference in functionality between Google-managed notebooks and Jose’s solution. While managed notebooks shut down after a period of inactivity, Jose’s solution shuts them down after a specified amount of time, regardless of activity. Keep this distinction in mind.

Setup

The implementation consists of a Cloud Scheduler and a Cloud Function.

The Cloud Scheduler runs every 5 minutes calling the Cloud Function to check for notebooks that reached the shutdown time.

Per default, the Cloud Function checks Vertex AI Notebooks in the region us-central1 if needed, add more regions to the region list.

To set this up, follow the steps in the GitHub repository. Well-done and quick setup using Terraform.

GitHub — jbrache/notebooks-auto-shutdown: Auto shut down your user-managed notebooks across your… \ This template demonstrates how to shutdown a Vertex AI user-managed notebook (UmN) after a specified number of seconds…\ github.com

Cloud bill shouldn't be a mystery

One platform for AI and Cloud optimization.

Required Permissions / Roles

It’s worth mentioning that the Cloud Function’s service account needs the following permissions to stop the notebooks and list the projects.

  • roles/browser on the organization level to iterate over all projects in a specific organization. Not needed if you want to execute this in the same project as your Cloud Function is deployed.
  • roles/notebooks.serviceAgent to list and stop the notebooks in the projects. If you want to shut down the notebook across projects, set this on…