Create a runtime template in Colab Enterprise

This page shows you how to create a runtime templatein Colab Enterprise.

To run code in your notebook, you use a compute resource called aruntime.You can use the default runtime or a runtime created from a runtime template.By creating a runtime template, you can configure the template to optimizea runtime's performance, cost, and other characteristics based on your needs.

Learn more aboutruntimes and runtime templates.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Vertex AI, Dataform, and Compute Engine APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Vertex AI, Dataform, and Compute Engine APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

Required roles

To get the permissions that you need to create a runtime template in Colab Enterprise, ask your administrator to grant you the Colab Enterprise Admin (roles/aiplatform.colabEnterpriseAdmin) IAM role on the project. For more information about granting roles, seeManage access to projects, folders, and organizations.

You might also be able to get the required permissions throughcustom roles or otherpredefined roles.

One or more of the required roles includes thedataform.repositories.list permission. Users who are granted thedataform.repositories.list permission or theCode Creator (roles/dataform.codeCreator) role in a project can list the names of code assets in that project by using the Dataform API or the Dataform command-line interface (CLI). Non-administrators using BigQuery Studio can only see code assets that they created or that were shared with them.

Create the runtime template

To create a runtime template, you can use the Google Cloud console,the Google Cloud CLI, the REST API, or Terraform.

Console

To create a runtime template:

  1. In the Google Cloud console, go to the Colab EnterpriseRuntime templates page.

    Go to Runtime templates

  2. Click New template.

    TheCreate new runtime template dialog appears.

Runtime basics

  1. In theRuntime basics section, enter aDisplay name.

  2. In theRegion menu, select the region where you want your runtime template.

  3. Optional: Add aDescription of your runtime template.

  4. Optional: To add a label, click Add label, and then enter aKey andValue pair. To add more labels, repeat this step.

  5. ClickContinue.

Configure compute

  1. In theConfigure compute section, in theMachine type menu, select a machine type. For information on machine types, see theMachine families resource and comparison guide.

    If you select a machine type that has GPUs, select theAccelerator type andAccelerator count. If you're unable to select the number of GPUs that you want, you might need to increase your quota. SeeRequest a quota adjustment.

  2. In theData disk type menu, select a disk type.

  3. In theData disk size field, enter a size in GB.

  4. In theIdle shutdown section:

    • To turn off idle shutdown, clearEnable idle shutdown.

    • To change the inactivity time period, inTime of inactivity before shutdown (Minutes), change the number to the number of minutes of inactivity that you want. In the Google Cloud console, this setting can be set to any integer value from 10 to 1440.

  5. ClickContinue.

Environment

  1. In theEnvironment section, select anEnvironment. The default isLatest (currently Python 3.12).

  2. Optional: In thePost-startup script field, enter the URI for a post-startup script. For more information about using a post-startup script, seeUse a post-startup script.

  3. Optional: Under the post-startup script URL, select your post-startup script's behavior. The default behavior isRun once. For more information, seePost-startup script behavior.

  4. Optional: To add an environment variable, click Add env variable, and then enter aKey andValue pair. To add more environment variables, repeat this step.

  5. ClickContinue.

Networking and security

  1. In theNetworking and security section, in theNetwork menu, select a network. If you don't select a network, your default network is selected.

  2. In theSubnetwork menu, select a subnetwork.

  3. To turn off public internet access, clearEnable public internet access.

  4. To turn off end-user credential access, clearEnable end-user credentials.

Finish creating the runtime template

ClickCreate to finish creating the runtime template.

Your runtime template appears in the list on theRuntime templates tab.

gcloud

Before using any of the command data below, make the following replacements:

  • DISPLAY_NAME: the display name of your runtime template.
  • PROJECT_ID: your project ID.
  • REGION: the region where you want your runtime template.
  • MACHINE_TYPE: themachine type to use for your runtime.
  • ACCELERATOR_TYPE: the type of hardware accelerator to use for your runtime.
  • ACCELERATOR_COUNT: the number of accelerators to use for your runtime.

Execute the following command:

Linux, macOS, or Cloud Shell

Note: Ensure you have initialized the Google Cloud CLI with authentication and a project by running eithergcloud init; orgcloud auth login andgcloud config set project.
gcloudcolabruntime-templatescreate--display-name="DISPLAY_NAME"\--project=PROJECT_ID\--region=REGION\--machine-type=MACHINE_TYPE\--accelerator-type=ACCELERATOR_TYPE\--accelerator-count=ACCELERATOR_COUNT

Windows (PowerShell)

Note: Ensure you have initialized the Google Cloud CLI with authentication and a project by running eithergcloud init; orgcloud auth login andgcloud config set project.
gcloudcolabruntime-templatescreate--display-name="DISPLAY_NAME"`--project=PROJECT_ID`--region=REGION`--machine-type=MACHINE_TYPE`--accelerator-type=ACCELERATOR_TYPE`--accelerator-count=ACCELERATOR_COUNT

Windows (cmd.exe)

Note: Ensure you have initialized the Google Cloud CLI with authentication and a project by running eithergcloud init; orgcloud auth login andgcloud config set project.
gcloudcolabruntime-templatescreate--display-name="DISPLAY_NAME"^--project=PROJECT_ID^--region=REGION^--machine-type=MACHINE_TYPE^--accelerator-type=ACCELERATOR_TYPE^--accelerator-count=ACCELERATOR_COUNT

For more information about the command for creating aruntime template from the command line, see thegcloud CLIdocumentation.

REST

Before using any of the request data, make the following replacements:

  • REGION: the region where you want your runtime template.
  • PROJECT_ID: your project ID.
  • DISPLAY_NAME: the display name of your runtime template.
  • MACHINE_TYPE: themachine type to use for your runtime.
  • ACCELERATOR_TYPE: the type of hardware accelerator to use for your runtime.
  • ACCELERATOR_COUNT: the number of accelerators to use for your runtime.

HTTP method and URL:

POST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/notebookRuntimeTemplates

Request JSON body:

{  "displayName": "DISPLAY_NAME",  "machineSpec": {    {      "machineType":MACHINE_TYPE      "acceleratorType":ACCELERATOR_TYPE,      "acceleratorCount":ACCELERATOR_COUNT,    }  },}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/notebookRuntimeTemplates"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/notebookRuntimeTemplates" | Select-Object -Expand Content
If successful, the response body contains an instance ofOperation.

For more information, see thenotebookRuntimeTemplates.create REST APIdocumentation.

Terraform

To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands. For more information, see theTerraform provider reference documentation.

The following sample uses thegoogle_colab_runtime_template Terraform resource to create a Vertex AI runtime template.

resource"google_compute_network""my_network"{name="{{index $.Vars "network_name"}}"auto_create_subnetworks=false}resource"google_compute_subnetwork""my_subnetwork"{name="{{index $.Vars "network_name"}}"network=google_compute_network.my_network.idregion="us-central1"ip_cidr_range="10.0.1.0/24"}resource"google_colab_runtime_template" "{{$.PrimaryResourceId}}"{name="{{index $.Vars "runtime_template_name"}}"display_name="Runtime template full"location="us-central1"description="Full runtime template"machine_spec{machine_type="n1-standard-2"accelerator_type="NVIDIA_TESLA_T4"accelerator_count="1"}data_persistent_disk_spec{disk_type="pd-standard"disk_size_gb=200}network_spec{enable_internet_access=truenetwork=google_compute_network.my_network.idsubnetwork=google_compute_subnetwork.my_subnetwork.id}labels={k="val"}idle_shutdown_config{idle_timeout="3600s"}euc_config{euc_disabled=false}shielded_vm_config{enable_secure_boot=false}network_tags=["abc", "def"]encryption_spec{kms_key_name="{{index $.Vars "key_name"}}"}software_config{env{name="TEST"value=1}post_startup_script_config{post_startup_script="echo 'hello world'"post_startup_script_url="gs://colab-enterprise-pss-secure/secure_pss.sh"post_startup_script_behavior="RUN_ONCE"}}}

Granting access to the runtime template

After you create a runtime template, you must grant access to itfor a principal to be able to use it. A principal cancreate a runtimefrom a runtime template only when they have the following:

  • Access to the runtime template.
  • The required permissions for creating runtimes.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.