在 Colab Enterprise 連線至執行階段

本頁說明如何連線至 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 使用者 (roles/aiplatform.colabEnterpriseUser) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

連線至預設執行階段

首次在筆記本中執行程式碼時,除非指定其他執行階段,否則 Colab Enterprise 會自動連線至預設執行階段。

如要連線至預設執行階段,但不要執行程式碼,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的 Colab Enterprise「我的筆記本」頁面。

    前往「我的筆記本」

  2. 在「Region」(區域) 選單中,選取包含筆記本的區域。

  3. 按一下要開啟的筆記本。如果尚未建立筆記本,請建立筆記本

  4. 在筆記本中,按一下「連線」

  5. 如果這是您第一次連結啟用使用者憑證的執行階段,系統會顯示「登入」對話方塊。

    如要授予 Colab Enterprise 使用者憑證存取權,請完成下列步驟:

    1. 在「登入」對話方塊中,按一下您的使用者帳戶。

    2. 選取「查看、編輯、設定和刪除您的資料...」,授予 Colab Enterprise 存取使用者憑證的權限。 Google Cloud

      勾選方塊旁邊的聲明內容為「查看、編輯、設定及刪除您的 Google Cloud 資料,以及查看您的 Google 帳戶電子郵件地址」。
    3. 按一下「繼續」

Colab Enterprise 會連線至預設執行階段,如果預設執行階段未執行,Colab Enterprise 會啟動預設執行階段,然後連線至該執行階段。

連線至現有的執行階段

本節說明如何使用「Connect to Agent Platform runtime」(連結至 Agent Platform Runtime) 對話方塊,連結至現有執行階段。

必要的角色

如要取得連線至 Colab Enterprise 筆記本中現有執行階段所需的權限,請要求管理員授予您專案的 Colab Enterprise 使用者 (roles/aiplatform.colabEnterpriseUser) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

連線至現有執行階段

如要連線至現有的執行階段:
  1. 前往 Google Cloud 控制台的 Colab Enterprise「我的筆記本」頁面。

    前往「我的筆記本」

  2. 在「Region」(區域) 選單中,選取包含筆記本的區域。

  3. 按一下要開啟的筆記本。如果尚未建立筆記本,請建立筆記本

  4. 在筆記本中,按一下「其他連線選項」展開箭頭,然後選取「連線到執行階段」

    「連結至 Agent Platform Runtime」對話方塊隨即開啟。

  5. 在「選取執行階段」部分,選取「連線至現有的執行階段」

  6. 如要選取現有的執行階段選項,請選取要連結的執行階段。如果清單中沒有任何執行階段,請建立執行階段連線至預設執行階段

  7. 按一下「連線」

  8. 如果您的執行階段已啟用使用者憑證,且您是第一次連線至已啟用使用者憑證的執行階段,系統會顯示「登入」對話方塊。

    如要授予 Colab Enterprise 使用者憑證存取權,請完成下列步驟:

    1. 在「登入」對話方塊中,按一下您的使用者帳戶。

    2. 選取「查看、編輯、設定和刪除您的資料...」,授予 Colab Enterprise 存取使用者憑證的權限。 Google Cloud

      勾選方塊旁邊的聲明內容為「查看、編輯、設定及刪除您的 Google Cloud 資料,以及查看您的 Google 帳戶電子郵件地址」。
    3. 按一下「繼續」

Colab Enterprise 會連線至執行階段。如果執行階段未執行,Colab Enterprise 會啟動執行階段,然後連線至該執行階段。

建立執行階段

本節說明如何建立執行階段,並使用「連結至 Agent Platform Runtime」對話方塊連結至執行階段。您也可以從「執行階段」分頁建立執行階段

必要的角色

如要取得在 Colab Enterprise 中建立執行階段所需的權限,請要求管理員授予您專案的 Colab Enterprise 管理員 (roles/aiplatform.colabEnterpriseAdmin) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

建立並連線至執行階段

如要建立執行階段並使用「Connect to Agent Platform runtime」(連結至 Agent Platform Runtime) 對話方塊連結至執行階段,請按照下列步驟操作:
  1. 前往 Google Cloud 控制台的 Colab Enterprise「我的筆記本」頁面。

    前往「我的筆記本」

  2. 在「Region」(區域) 選單中,選取包含筆記本的區域。

  3. 按一下要開啟的筆記本。如果尚未建立筆記本,請建立筆記本

  4. 在筆記本中,按一下「其他連線選項」展開箭頭,然後選取「連線到執行階段」

    「連結至 Agent Platform Runtime」對話方塊隨即開啟。

  5. 在「選取執行階段」部分,選取「建立新的執行階段」

  6. 在「執行階段範本」選單中,選取執行階段範本。如果沒有列出任何執行階段範本,請建立執行階段範本

  7. 在「Runtime name」(執行階段名稱) 欄位中,輸入執行階段的名稱。

  8. 按一下「連線」

  9. 如果您選取的執行階段範本已啟用使用者憑證,且這是您首次連線至已啟用使用者憑證的執行階段,系統會顯示「登入」對話方塊。

    如要授予 Colab Enterprise 使用者憑證存取權,請完成下列步驟:

    1. 在「登入」對話方塊中,按一下您的使用者帳戶。

    2. 選取「查看、編輯、設定和刪除您的資料...」,授予 Colab Enterprise 存取使用者憑證的權限。 Google Cloud

      勾選方塊旁邊的聲明內容為「查看、編輯、設定及刪除您的 Google Cloud 資料,以及查看您的 Google 帳戶電子郵件地址」。
    3. 按一下「繼續」

Colab Enterprise 會啟動預設執行階段,然後連線至該執行階段。

執行階段管理

根據預設,您建立執行階段時,系統會自動授予刪除 (aiplatform.googleapis.com/notebookRuntimes.delete) 和啟動 (aiplatform.googleapis.com/notebookRuntimes.start) 該執行階段的必要權限。

如要瞭解如何管理執行階段 (包括刪除、啟動或中斷連線),請參閱「管理執行階段」。

疑難排解

本節說明如何解決 Colab Enterprise 中連線至執行階段的問題。

無法連線至執行階段

造成這個問題的原因有很多,最常見的原因如下:

瀏覽器封鎖第三方 Cookie

您使用的瀏覽器封鎖了第三方 Cookie,而 Colab Enterprise 會使用這類 Cookie 與執行階段建立 HTTPS 連線。

如要解決這個問題,請將瀏覽器設定為允許來自網域 DATALAB_TUNNEL_TOKEN*.aiplatform-notebook.googleusercontent.com 的第三方 Cookie。

網路封鎖傳送至筆記本網域的輸出流量

您網路的防火牆規則會封鎖傳出流量,使其無法連至 *.aiplatform-notebook.cloud.google.com*aiplatform.googleapis.com

如要解決這個問題,請設定網路的防火牆規則,允許輸出流量連到 *.aiplatform-notebook.cloud.google.com*aiplatform.googleapis.com

後續步驟