簡體   English   中英

使用 aws Sagemaker 運行訓練作業時出錯

[英]error to run training job with aws Sagemaker

我正在嘗試使用 github 示例將我自己的病態學習 ML 模型與 SageMaker 一起使用。

python代碼如下:

# Define IAM role import boto3 
import re 
import os 
import numpy as np 
import pandas as pd 
from sagemaker import get_execution_role 
import sagemaker as sage from time 
import gmtime, strftime 
role = get_execution_role()

ess =  sage.Session()
account = sess.boto_session.client('sts').get_caller_identity()['Account']
region = sess.boto_session.region_name
image = '{}.dkr.ecr.{}.amazonaws.com/decision-trees-sample:latest'.format(account, region)


output_path="s3://output"

sess

tree = sage.estimator.Estimator(image,
                      role, 1, 'ml.c4.2xlarge',
                     output_path='s3-eu-west-1.amazonaws.com/output',
                    sagemaker_session=sess)

tree.fit("s3://output/iris.csv")

但我收到此錯誤:

信息:sagemaker:使用名稱創建訓練作業:decision-trees-sample-2018-04-24-13-13-38-281

-------------------------------------------------- ------------------------- ClientError Traceback (最近調用 last) in () 14 sagemaker_session=sess) 15 ---> 16 tree.fit (“s3://inteldatastore-cyrine/iris.csv”)

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/estimator.py in fit(self, input, wait, logs, job_name) 161 self.output_path = 's3://{}/' .format(self.sagemaker_session.default_bucket()) 162 --> 163 self.latest_training_job = _TrainingJob.start_new(self,inputs) 164 如果等待:165 self.latest_training_job.wait(logs=logs)

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/estimator.py in start_new(cls, estimator, input) 336 input_config=input_config, role=role, job_name=estimator._current_job_name, 337 output_config= output_config, resource_config=resource_config, --> 338 hyperparameters=hyperparameters, stop_condition=stop_condition) 339 340 return cls(estimator.sagemaker_session, estimator._current_job_name)

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/session.py in train(self, image, input_mode, input_config, role, job_name, output_config, resource_config, hyperparameters, stop_condition) 242 LOGGER.info ('Creating training-job with name: {}'.format(job_name)) 243 LOGGER.debug('train request: {}'.format(json.dumps(train_request, indent=4))) --> 244 self .sagemaker_client.create_training_job(**train_request) 245 246 def create_model(self, name, role, primary_container):

~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in _api_call(self, *args, **kwargs) 312 "%s() 只接受關鍵字參數。" % py_operation_name) 313 # 這個范圍內的“self”是指BaseClient。 --> 314 返回 self._make_api_call(operation_name, kwargs) 315 316 _api_call。 名稱= str(py_operation_name)

~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params) 610 error_code = parsed_response.get("Error", {}).get("代碼") 611 error_class = self.exceptions.from_code(error_code) --> 612 raise error_class(parsed_response, operation_name) 613 else: 614 return parsed_response

ClientError:調用 CreateTrainingJob 操作時發生錯誤 (AccessDeniedException):用戶:arn:aws:sts::307504647302:assumed-role/default/SageMaker 未被授權執行:sagemaker:CreateTrainingJob on resource: arn:aws:sagemaker: eu-west-1:307504647302:training-job/decision-trees-sample-2018-04-24-13-13-38-281

你能幫我解決問題嗎?

謝謝

也許您正在使用 AWS Educate 帳戶。

目前,您無法使用 SageMaker 服務通過 AWS Educate Starter 賬戶創建訓練或建模作業。

目前,如果您想使用/部署帶有 SageMaker 服務的訓練作業,您可以使用自己的個人 AWS 賬戶。

但是,您可以通過 AWS Educate 賬戶通過 SageMaker 繼續使用 Jupyter 筆記本。

您似乎無權訪問該資源

arn:aws:sagemaker:eu-west-1:307504647302:training-job/decision-trees-sample-2018-04-24-13-13-38-281

您能否檢查資源 url 是否正確以及在安全組中設置了正確的權限。

我在開始使用 SageMaker 時遇到了類似的問題,所以我開發了這個開源項目https://github.com/Kenza-AI/sagify (sagify),它是一個 CLI 工具,可以幫助您訓練和部署自己的機器學習/ SageMaker 上的深度學習模型非常簡單。 我設法訓練和部署了我所有的 ML 模型,無論我使用的是什么庫(Keras、Tensorflow、scikit-learn、LightFM、spacy 等)。 本質上,您可以以經典的 Pythonic 方式指定所有依賴項,即在 requiments.txt 中,sagify 將讀取它們並將它們安裝在 Docker 映像上。 然后,可以在 SageMaker 上執行此 Docker 映像以進行訓練和部署。

此外,我在 sagify 文檔 ( https://kenza-ai.github.io/sagify/ ) 中指定了一個關於如何設置您的 AWS 賬戶以避免與權限相關的問題的一次性過程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM