使用预留

本文档介绍了如何使用 Compute Engine 预留 来确保您的 Colab Enterprise 运行时 具有运行所需的足够的虚拟机 (VM) 资源。

预留是 Compute Engine 的一项功能。它们有助于确保您随时可以使用资源来创建具有相同硬件(内存和 vCPU)和可选资源(GPU 和本地 SSD 磁盘)的虚拟机。

当您创建预留时,Compute Engine 会验证指定可用区是否有可用的请求容量。如果有,Compute Engine 会预留资源并创建预留,然后会发生以下情况:

  • 预留的资源会立即可供您使用,并且这些资源会一直可用,直到您删除预留为止。

  • 系统会按照与运行中虚拟机相同的按需费率(包括任何适用的折扣)对预留的资源收费,直到您删除预留为止。使用预留时,虚拟机不会产生重复的资源费用,因为系统已针对预留资源的费用收取预留的费用。如需了解详情, 请参阅 Compute Engine 可用区级资源的预留

概览

如需将预留与 Colab Enterprise 搭配使用,请执行以下任务:

  1. 创建预留

  2. 将预留添加到新的运行时模板

  3. 使用预留通过在从 您的运行时模板派生的运行时中运行代码。

限制和要求

当 Colab Enterprise 运行时使用预留时,需要遵循 Compute Engine 预留的所有限制。请参阅预留的工作原理 。

此外,将预留与 Colab Enterprise 搭配使用时,存在以下限制和要求:

  • 承诺使用折扣不适用。

  • 预留必须符合以下条件之一:

    • 与 Colab Enterprise 笔记本和运行时位于同一项目中。
    • 与 Colab Enterprise 笔记本和运行时位于同一项目中,并与该项目共享。
  • 预留的虚拟机属性必须与 Colab Enterprise 运行时完全匹配才能使用该预留。例如,如果预留指定了 e2-standard-8 机器类型,则只有在 Colab Enterprise 运行时也使用 e2-standard-8 机器类型时才能使用该预留。请参阅 要求

准备工作

  1. 查看预留的 要求 限制
  2. 查看共享预留的 配额要求 限制
  3. 登录您的 Google Cloud 账号。如果您是新手 Google Cloud, 请创建一个账号来评估我们的产品在 实际场景中的表现。新客户还可获享 $300 赠金,用于 运行、测试和部署工作负载。
  4. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

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

  6. 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 the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  7. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

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

  9. 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 the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

所需的角色

如需获得将预留与 Colab Enterprise 搭配使用所需的权限,请让您的管理员为您授予项目的以下 IAM 角色:

如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

您也可以通过自定义角色或其他预定义角色来获取所需的权限。

创建预留

创建 Compute Engine 预留。它可以是单项目预留,也可以是共享预留。如需了解详情,请参阅以下文档:

预留可以包含 GPU 加速器。

将预留添加到新的运行时模板

如需创建使用预留的运行时模板,请执行以下操作:
  1. 在 Google Cloud 控制台中,前往 Colab Enterprise 运行时模板 页面。

    进入运行时模板

  2. 点击  新建模板

    此时会显示创建新的运行时模板 对话框。

  3. 运行时基本信息 部分中,输入 显示名称

  4. 区域 菜单中,选择需要运行时模板的区域。

  5. 配置计算 部分的机器类型 菜单中,选择机器类型。运行时模板的机器类型必须与预留的 机器类型匹配。

  6. 预留 菜单中,选择要使用的特定 预留,或选择 使用自动选择的预留

    如需详细了解如何使用自动选择或 明确指定的预留,请参阅 使用类型部分,了解 预留的工作原理

  7. 完成对话框的其余部分,然后点击 创建

    您的运行时模板会显示在 运行时模板 标签页上的列表中。

使用预留

如需使用预留,请执行以下操作:

  1. 通过新的运行时模板创建运行时 。

  2. 打开或创建笔记本

  3. 在笔记本中,连接到运行时, 并运行代码。

停止使用预留

如需停止使用预留,您可以 删除预留

如果您希望继续将您的预留用于其他资源,但不希望 Colab Enterprise 笔记本使用它,请删除与预留关联的运行时和运行时模板。

结算

使用 Compute Engine 预留时,您需要为以下各项支付费用:

  • Compute Engine 资源,按 Compute Engine 价格收费。这些费用的 SKU 上带有标签 goog-vertex-ai-product: colab-enterprise。 请参阅 Compute Engine 价格

  • 除基础设施使用费之外,还需支付 Colab Enterprise 管理费。请参阅 Colab Enterprise 价格

问题排查

本部分介绍了如何解决将预留与 Colab Enterprise 搭配使用时遇到的问题。

无法创建运行时

尝试创建运行时时,会发生类似于以下内容的错误。

Failed to create notebook runtime with error: Invalid value for field
'resource.reservationAffinity': '{"consumeReservationType":
"SPECIFIC_ALLOCATION", "key": "compute.googleapis.com/reservation-name...'.
No available resources in specified reservations.

当预留的虚拟机属性与 Colab Enterprise 运行时不匹配时,会发生此错误。例如,如果预留指定了 e2-standard-8 机器类型, 则只有在 Colab Enterprise 运行时也使用 e2-standard-8 机器类型时才能使用该预留。如需了解详情, 请参阅要求

如需解决此问题,请创建运行时模板,其配置与 预留的虚拟机属性匹配。

后续步骤