簡體   English   中英

如何在 SageMaker 上運行和部署 AWS 的 XGBoost MNIST 示例筆記本?

[英]How to run and deploy AWS's XGBoost MNIST sample notebook on SageMaker?

我正在嘗試將Kubernetes SageMaker Operations與 XGBoost MNIST AWS 的示例一起使用

在啟用 Kubernetes SageMaker Ops 之前,我已經通過 SageMaker WebUI 本身部署了 XGBoost MNIST 示例,並嘗試通過 awscli 訪問端點:

$ aws sagemaker-runtime invoke-endpoint \
    --region eu-west-1 \
    --endpoint-name DEMO-XGBoostEndpoint-2020-11-20-06-26-30 \
    --body $(seq 784 | xargs echo | sed 's/ /,/g') \
    >(cat) \
    --content-type text/csv > /dev/null

但是,我遇到以下解碼錯誤:

An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (415) from model with message "Loading csv data failed with Exception, please ensure data is in csv format:
 <class 'UnicodeDecodeError'>
 'utf-8' codec can't decode byte 0xd7 in position 0: invalid continuation byte". See https://xxxx.console.aws.amazon.com/cloudwatch/home?region=xxxxx#logEventViewer:group=/aws/sagemaker/Endpoints/DEMO-XGBoostEndpoint-2020-11-20-06-26-30 in account XXX for more information.

在日志中我可以看到:

Traceback (most recent call last):
  File "/miniconda3/lib/python3.6/site-packages/sagemaker_xgboost_container/algorithm_mode/serve_utils.py", line 102, in parse_content_data
    decoded_payload = payload.strip().decode("utf-8")
Traceback (most recent call last): File "/miniconda3/lib/python3.6/site-packages/sagemaker_xgboost_container/algorithm_mode/serve_utils.py", line 102, in parse_content_data decoded_payload = payload.strip().decode("utf-8")

當我轉到sagemaker_xgboost_container的源代碼時,我可以看到他們期望使用 UTF-8 格式:

        decoded_payload = payload.strip().decode("utf-8")

我的locale看起來不錯,我真的不確定還有什么地方可能出錯:

$ locale
LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

我已經聯系了 AWS 支持,顯然這是awscli一個錯誤。 這是他們冗長而詳細的答案的修訂摘錄。

這是 AWSCLI v2 的編碼問題。 目前,您可以繼續使用 AWSCLI v1.18 作為臨時解決方案。

我還驗證了它適用於 aws-cli/1.18.185:

$ aws --version
aws-cli/1.18.185 Python/3.8.3 Linux/4.19.104-microsoft-standard botocore/1.19.25

$ aws sagemaker-runtime invoke-endpoint \
>     --region eu-west-1 \
>     --endpoint-name DEMO-XGBoostEndpoint-2020-11-20-06-26-30 \
>     --body $(seq 784 | xargs echo | sed 's/ /,/g') \
>     >(cat) \
>     --content-type text/csv > /dev/null
8.0%

在 AWS cli v2.1.21 中,亞馬遜添加了--cli-binary-format raw-in-base64-out選項,這應該可以與 AWS cli v1.18 一起使用:

aws sagemaker-runtime invoke-endpoint \
>     --region <aws-region> \
>     --endpoint-name <you-endpoint-name> \
>     --cli-binary-format raw-in-base64-out \
>     --body $(seq 784 | xargs echo | sed 's/ /,/g') \
>     >(cat) \
>     --content-type text/csv > /dev/null

暫無
暫無

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

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