[英]How to get an Amazon ECR container URI for a specific model image in Sagemaker?
I want to know if it's possible to get an Amazon ECR container URI for a specific image programmatically (using AWS CLI or Python).我想知道是否可以通过编程方式(使用 AWS CLI 或 Python)获取特定图像的 Amazon ECR 容器 URI。 For example, if I need the URL for the latest
linear-learner
(built-in model) image for the eu-central-1
region.例如,如果我需要 URL 作为
eu-central-1
区域的最新linear-learner
(内置模型)图像。
Expected result:预期结果:
664544806723.dkr.ecr.eu-central-1.amazonaws.com/linear-learner:latest
EDIT: I have found the solution with get_image_uri
.编辑:我找到了
get_image_uri
的解决方案。 It looks like this function will be depreceated and I don't know how to use ImageURIProvider
instead.看起来这个 function 将被弃用,我不知道如何使用
ImageURIProvider
来代替。
We can use the function get_image_uri
:我们可以使用函数
get_image_uri
:
from sagemaker.amazon.amazon_estimator import get_image_uri
region = boto3.Session().region_name
#or region = 'eu-central-1'
get_image_uri(region_name=region,
repo_name='linear-learner',
repo_version='latest')
Output:输出:
664544806723.dkr.ecr.eu-central-1.amazonaws.com/linear-learner:latest
Warning:警告:
'get_image_uri' method will be deprecated in favor of 'ImageURIProvider' class in SageMaker Python SDK v2.
It looks like this function will be deprecated and I can't find how to use ImageURIProvider
instead.看起来这个函数将被弃用,我找不到如何使用
ImageURIProvider
来代替。
The newer versions of SageMaker SDK have a more centralized API for getting the URIs:较新版本的 SageMaker SDK 具有用于获取 URI 的更集中的 API:
import sagemaker
sagemaker.image_uris.retrieve("linear-learner", "eu-central-1")
which gives the expected result:这给出了预期的结果:
664544806723.dkr.ecr.eu-central-1.amazonaws.com/linear-learner:1
from sagemaker import image_uris container = sagemaker.image_uris.retrieve("linear-learner", boto3.Session().region_name)从 sagemaker import image_uris container = sagemaker.image_uris.retrieve("linear-learner", boto3.Session().region_name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.