跳至內容

為什麼我在 SageMaker AI 筆記本執行個體或 SageMaker Studio 網域上啟動預先簽署網址時會收到錯誤訊息?

2 分的閱讀內容
0

我想在 Amazon SageMaker AI 筆記本執行個體或 Amazon SageMaker Studio 網域上啟動預先簽署網址,但收到錯誤訊息。

解決方法

**注意:**如果您在執行 AWS Command Line Interface (AWS CLI) 命令時收到錯誤訊息,請參閱對 AWS CLI 錯誤進行疑難排解。此外,請確定您使用的是最新的 AWS CLI 版本

當您在 SageMaker AI 筆記本執行個體或 SageMaker Studio 網域上啟動預先簽署的網址時,可能會收到下列錯誤訊息:

  • 「驗證權杖無效或已過期。請求新的預先簽署網址以繼續使用 SageMaker。」
  • 「使用者:arn:aws:sts::account id:assumed-role/IAM role/IAM user 無權對資源:arn:aws:sagemaker:Region:account id:notebook-instance/notebook instance 執行:sagemaker:CreatePresignedNotebookInstanceUrl,因為沒有身分型政策允許 sagemaker:CreatePresignedNotebookInstanceUrl 動作」
  • 「使用者:arn:aws:sts::account id:assumed-role/IAM role/SageMaker 無權對資源:arn:aws:sagemaker:Region:account id:user-profile/domain id/user profile name 執行:sagemaker:CreatePresignedDomainUrl,因為沒有身分型政策允許 sagemaker:CreatePresignedDomainUrl 動作」

若要對這些問題進行疑難排解,請根據您收到的錯誤訊息完成相應的解決方案。

「驗證權杖無效或已過期」錯誤

CreatePresignedNotebookInstanceUrlCreatePresignedDomainUrl 中的 SessionExpirationDurationInSeconds 參數超過最長持續時間 12 小時限制時,您會收到驗證權杖無效或已過期錯誤。若要解決此問題,請清除 Web 瀏覽器中的 Cookie 和工作階段資料。然後,使用 SageMaker AI 主控台、AWS CLI 或 Python SDK 產生新的預先簽署網址。

SageMaker AI 筆記本執行個體

若要使用主控台,請完成下列步驟:

  1. 開啟 SageMaker AI console (SageMaker AI 主控台)。
  2. 在導覽窗格中的 Applications and IDEs (應用程式和 IDE) 下,選擇 Notebooks (筆記本)。
  3. 選取您的筆記本執行個體。
  4. 選擇 Open Jupyter (開啟 Jupyter) 或 Open JupyterLab (開啟 JupyterLab)。

若要使用 AWS CLI,請執行 create-presigned-notebook-instance-url 命令:

aws sagemaker create-presigned-notebook-instance-url --notebook-instance-name example-notebook-instance-name --session-expiration-duration-in-seconds example-session-expiration-duration

**注意:**將 example-notebook-instance-nameexample-session-expiration-duration 替換為您的值。

若要使用 Python SDK Boto3,請執行 create-presigned-notebook-instance-url 命令:

import boto3

client = boto3.client('sagemaker')

response = client.create_presigned_notebook_instance_url(
    NotebookInstanceName=example-notebook-name,
    SessionExpirationDurationInSeconds=example-session-expiration-duration
)

**注意:**將 example-notebook-nameexample-session-expiration-duration 替換為您的值。

AWS CLI 或 Python SDK 產生的預先簽署網址僅在 5 分鐘內有效。5 分鐘後,您必須產生新的預先簽署網址。

SageMaker Studio 網域

若要使用主控台,請完成下列步驟:

  1. 開啟 SageMaker AI console (SageMaker AI 主控台)。
  2. 在導覽窗格的 Admin configurations (管理員組態) 下,選擇 Domains (網域)。
  3. 選取您的網域。
  4. 選擇 User profiles (使用者設定檔),然後選取您的使用者設定檔名稱。
  5. 選擇 Launch (啟動),然後選擇 Studio (工作室)。

若要使用 AWS CLI,請執行 create-presigned-domain-url 命令:

aws sagemaker create-presigned-domain-url --domain-id example-domain-id --user-profile-name example-user-profile-name --session-expiration-duration-in-seconds example-session-expiration-duration

**注意:**將 example-domain-idexample-user-profile-nameexample-session-expiration-duration 替換為您的值。

若要使用 Python SDK Boto3,請執行 create-presigned-domain-url 命令:

import boto3

client = boto3.client('sagemaker')

response = client.create_presigned_domain_url(
    DomainId=example-domain-id,
    UserProfileName=example-user-profile-name,
    SessionExpirationDurationInSeconds=example-session-expiration-duration,
)

**注意:**將 example-domain-idexample-user-profile-nameexample-session-expiration-duration 替換為您的值。

AWS CLI 或 Python SDK 產生的預先簽署網址僅在 5 分鐘內有效。5 分鐘後,您必須產生新的預先簽署網址。

「無權執行」錯誤

若要啟動 SageMaker AI 筆記本或 SageMaker Studio 網域,您的 AWS Identity and Access Management (IAM) 角色必須具有建立預先簽署網址的權限。

如果是 SageMaker AI 筆記本執行個體,請將 sagemaker:CreatePresignedNotebookInstanceUrl 動作新增至 IAM 角色的驗證型政策中。如果是 SageMaker Studio 網域,請將 sagemaker:CreatePresignedDomainUrl 動作新增至 IAM 政策。

相關資訊

透過 Amazon Virtual Private Cloud (Amazon VPC) 介面端點連線到筆記本執行個體

AWS 官方已更新 1 年前