本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
建立共用空間
允許 Amazon SageMaker Studio 或 Amazon SageMaker Studio Classic 建立 Amazon SageMaker 資源的自訂 IAM 政策也必須授予許可,才能將標籤新增至這些資源。需要將標籤新增至資源的許可,因為 Studio 和 Studio Classic 會自動標記他們建立的任何資源。如果 IAM 政策允許 Studio 和 Studio Classic 建立資源,但不允許標記,則嘗試建立資源時可能會發生「AccessDenied」錯誤。如需詳細資訊,請參閱提供標記 SageMaker AI 資源的許可。
AWS Amazon SageMaker AI 的 受管政策 提供建立 SageMaker 資源的許可,已包含建立這些資源時新增標籤的許可。
下列主題示範如何在現有的 Amazon SageMaker AI 網域中建立共用空間。如果您建立的網域不支援共用空間,您必須先將共用空間的支援新增至現有網域,才能建立共用空間。
將共用空間支援新增至現有網域
您可以使用 SageMaker AI 主控台或 AWS CLI ,將共用空間的支援新增至現有網域。如果網域使用VPC only
網路存取,則您只能使用 新增共用空間支援 AWS CLI。
主控台
完成下列程序,從 SageMaker AI 主控台將 Studio Classic 共用空間的支援新增至現有網域。
AWS CLI
- Studio Classic
-
從本機電腦的終端機執行下列命令,從 將預設共用空間設定新增至網域 AWS CLI。如果您要將預設共用空間設定新增至 Amazon VPC 內的網域,您還必須包含安全群組清單。Studio Classic 共用空間僅支援使用 JupyterLab 3 映像 ARNs。如需詳細資訊,請參閱JupyterLab 版本控制。
# Public Internet domain
aws --region region
\
sagemaker update-domain \
--domain-id domain-id
\
--default-space-settings "ExecutionRole=execution-role-arn
,JupyterServerAppSettings={DefaultResourceSpec={InstanceType=example-instance-type
,SageMakerImageArn=sagemaker-image-arn
}}"
# VPCOnly domain
aws --region region
\
sagemaker update-domain \
--domain-id domain-id
\
--default-space-settings "ExecutionRole=execution-role-arn
,JupyterServerAppSettings={DefaultResourceSpec={InstanceType=system,SageMakerImageArn=sagemaker-image-arn
}},SecurityGroups=[security-groups
]"
使用下列命令來驗證預設共用空間設定是否已更新。
aws --region region
\
sagemaker describe-domain \
--domain-id domain-id
- JupyterLab
-
從本機電腦的終端機執行下列命令,從 將預設共用空間設定新增至網域 AWS CLI。如果您要將預設共用空間設定新增至 Amazon VPC 內的網域,您還必須包含安全群組清單。Studio Classic 共用空間僅支援使用 JupyterLab 4 映像 ARNs。如需詳細資訊,請參閱JupyterLab 版本控制。
# Public Internet domain
aws --region region
\
sagemaker update-domain \
--domain-id domain-id
\
--default-space-settings "ExecutionRole=execution-role-arn
", JupyterLabAppSettings={DefaultResourceSpec={InstanceType=example-instance-type
,SageMakerImageArn=sagemaker-image-arn
}}"
# VPCOnly domain
aws --region region
\
sagemaker update-domain \
--domain-id domain-id
\
--default-space-settings "ExecutionRole=execution-role-arn
, SecurityGroups=[security-groups
]"
使用下列命令來驗證預設共用空間設定是否已更新。
aws --region region
\
sagemaker describe-domain \
--domain-id domain-id
建立共用空間
下列各節示範如何從 Amazon SageMaker AI 主控台、Amazon SageMaker Studio 或 建立共用空間 AWS CLI。
使用下列程序,從 Studio 在網域中建立共用空間。
- Studio Classic
-
-
依照中的步驟導覽至 Studio啟動 Amazon SageMaker Studio。
-
從 Studio UI 中,尋找左側的應用程式窗格。
-
從應用程式窗格中,選取 Studio Classic。
-
選擇建立 Studio Classic 空間
-
在快顯視窗中,輸入空格的名稱。
-
選擇建立空間。
- JupyterLab
-
-
依照中的步驟導覽至 Studio啟動 Amazon SageMaker Studio。
-
從 Studio UI 中,尋找左側的應用程式窗格。
-
從應用程式窗格中,選取 JupyterLab。
-
選擇建立 JupyterLab 空間
-
在快顯視窗中,輸入空格的名稱。
-
選擇建立空間。
完成下列程序,從 SageMaker AI 主控台在網域中建立共用空間。
本節說明如何從 AWS CLI建立共用空間。
建立或更新共用空間時,您無法設定共用空間的執行角色。只能在建立或更新網域時設定 DefaultDomainExecRole
。 共用空間僅支援使用 JupyterLab 3 映像 ARNs。如需詳細資訊,請參閱JupyterLab 版本控制。
若要從 建立共用空間 AWS CLI,請從本機機器的終端機執行下列其中一個命令。
- Studio Classic
-
aws --region region
\
sagemaker create-space \
--domain-id domain-id
\
--space-name space-name
\
--space-settings '{
"JupyterServerAppSettings": {
"DefaultResourceSpec": {
"SageMakerImageArn": "sagemaker-image-arn
",
"InstanceType": "system"
}
}
}'
- JupyterLab
-
aws --region region
\
sagemaker create-space \
--domain-id domain-id
\
--space-name space-name
\
--ownership-settings "{"OwnerUserProfileName": "user-profile-name
"}" \
--space-sharing-settings "{"SharingType": "Shared"}" \
--space-settings "{"AppType": "JupyterLab"}"