连接到运行时

本页面介绍了如何在 Colab Enterprise 中连接到运行时。

如需在笔记本中运行代码,您必须连接到运行时。运行时是运行代码的计算资源。

准备工作

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

    Go to project selector

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

  4. Enable the Agent Platform, Dataform, and Compute Engine APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

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

  7. Enable the Agent Platform, Dataform, and Compute Engine APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

使用不同方法连接

本页面介绍了如何使用以下方法连接到运行时:

使用默认运行时

本部分介绍了如何连接到默认运行时。

所需的角色

如需获得连接到 Colab Enterprise 笔记本中的默认运行时所需的权限,请让您的管理员为您授予项目的 Colab Enterprise User (roles/aiplatform.colabEnterpriseUser) IAM 角色。如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

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

连接到默认运行时

当您首次在笔记本中运行代码时,Colab Enterprise 会自动连接到默认运行时,除非您 指定了其他运行时

如需连接到默认运行时而不运行代码,请执行以下操作:

  1. 在 Google Cloud 控制台中,前往 Colab Enterprise 我的笔记本页面。

    前往我的笔记本

  2. 区域菜单中,选择包含笔记本的区域。

  3. 点击您要打开的笔记本。如果您尚未创建笔记本,请创建一个笔记本

  4. 在笔记本中,点击连接

  5. 如果这是您第一次连接到启用了最终用户凭据的运行时,系统会显示登录对话框。

    如需为 Colab Enterprise 授予对用户凭据的访问权限,请完成以下步骤:

    1. 登录对话框中,点击您的用户账号。

    2. 选择查看、修改、配置和删除您的 Google Cloud 数据...,为 Colab Enterprise 授予对用户凭证的访问权限。

      复选框在“查看、修改、配置和删除您的 Google Cloud 数据,并查看您的 Google 账号的电子邮件地址”句子的旁边。
    3. 点击继续

Colab Enterprise 会连接到默认运行时。如果默认运行时未运行,Colab Enterprise 会启动默认运行时,然后连接到该运行时。

连接到现有运行时

本部分介绍了如何使用连接到 Agent Platform 运行时 对话框连接到现有运行时。

所需的角色

如需获得连接到 Colab Enterprise 笔记本中的现有运行时所需的权限,请让您的管理员为您授予项目的 Colab Enterprise User (roles/aiplatform.colabEnterpriseUser) IAM 角色。如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

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

连接到现有运行时

如需连接到现有运行时,请执行以下操作:
  1. 在 Google Cloud 控制台中,前往 Colab Enterprise 我的笔记本页面。

    前往我的笔记本

  2. 区域菜单中,选择包含笔记本的区域。

  3. 点击您要打开的笔记本。如果您尚未创建笔记本,请创建一个笔记本

  4. 在笔记本中,点击其他连接选项 展开箭头, 然后选择连接到运行时

    系统会打开连接到 Agent Platform 运行时 对话框。

  5. 对于选择运行时, 选择连接到现有运行时

  6. 对于选择现有运行时选项,请选择要连接的运行时。如果列表中没有任何运行时,请创建运行时连接到默认运行时

  7. 点击连接

  8. 如果运行时启用了最终用户凭据,并且这是您第一次连接到启用了最终用户凭据的运行时,系统会显示登录对话框。

    如需为 Colab Enterprise 授予对用户凭据的访问权限,请完成以下步骤:

    1. 登录对话框中,点击您的用户账号。