amazon-web-services - 如何在 AWS Sagemaker 中查找不同区域的 XGBoost 容器
问题描述
我正在尝试按照 AWS Sagemaker 教程使用 Jupyter 笔记本环境训练机器学习模型。
根据教程,我应该复制以下代码并运行它以导入所需的库并设置环境变量。
# import libraries
import boto3, re, sys, math, json, os, sagemaker, urllib.request
from sagemaker import get_execution_role
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from IPython.display import Image
from IPython.display import display
from time import gmtime, strftime
from sagemaker.predictor import csv_serializer
# Define IAM role
role = get_execution_role()
prefix = 'sagemaker/DEMO-xgboost-dm'
containers = {'us-west-2': '433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest',
'us-east-1': '811284229777.dkr.ecr.us-east-1.amazonaws.com/xgboost:latest',
'us-east-2': '825641698319.dkr.ecr.us-east-2.amazonaws.com/xgboost:latest',
'eu-west-1': '685385470294.dkr.ecr.eu-west-1.amazonaws.com/xgboost:latest'} # each region has its XGBoost container
my_region = boto3.session.Session().region_name # set the region of the instance
print("Success - the MySageMakerInstance is in the " + my_region + " region. You will use the " + containers[my_region] + " container for your SageMaker endpoint.")
预期结果如下。
但是,我收到此错误。
KeyError Traceback (last recent call last) in () 18 'eu-west-1': '685385470294.dkr.ecr.eu-west-1.amazonaws.com/xgboost:latest'} # 每个区域都有自己的 XGBoost 容器 19 my_region = boto3.session.Session().region_name # 设置实例所在的区域 ---> 20 print("成功 - MySageMakerInstance 在 " + my_region + " 区域。您将使用 " + containers[my_region] + " SageMaker 端点的容器。")
KeyError:'ap-northeast-2'
我认为发生这种情况是因为我的区域是"ap-northeast-2"。我有一种感觉,我需要为我所在的地区更换容器。
如果我的猜测是正确的,我怎样才能找到我所在地区的容器?
另外,我是否忽略了其他任何事情?
解决方案
在此链接中找到您在 XGBoost (0.72) 中的训练图像和推理图像注册表路径: https ://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html
在您的情况下,它将是“ap-northeast-2”。使用相关的 ecr 将其添加到您的容器中。它应该可以正常工作。
推荐阅读
- amazon-web-services - Terraform 销毁失败 - 状态文件未更新
- linux - 如何在 linux 的 discord.py 中创建重启命令?即使它需要其他文件,如 shell 之类的
- javascript - 为什么当我使用 Intl.NumberFormat 格式化为欧元时,最后一位数字和欧元之间的空格与空格键不同?
- python - 如何键入可变的默认参数
- azure - Web 活动中使用的这些属性(数据集、链接服务、集成运行时、标头)是什么?
- class - 类继承实践
- c# - 调用 application.exit 并将值传递给 FormClosing
- r - 在 R 中手动执行线性回归
- solidity - Remix IDE 不显示子合同
- haskell - Haskell 阶乘实现