慕的地8271018
2023-04-25 17:31:10
我正在嘗試從 Postman 和 AWS CLI 調(diào)用我的 SageMaker 模型終端節(jié)點(diǎn)。端點(diǎn)的狀態(tài)是“服務(wù)中”,但每當(dāng)我嘗試調(diào)用它時(shí),它都會(huì)給我一個(gè)錯(cuò)誤。當(dāng)我嘗試在 SageMaker notebook 中使用預(yù)測(cè)函數(shù)并為其提供一個(gè) numpy 數(shù)組(例如np.array([1,2,3,4]))時(shí),它成功地為我提供了一個(gè)輸出。我不確定我做錯(cuò)了什么。$ aws2 sagemaker-runtime invoke-endpoint \$ --endpoint-name=pytorch-model \$ --body=1,2 \$ --content-type=text/csv \$ --cli-binary-format=raw-in-base64-out \$ output.jsonAn error occurred (ModelError) when calling the InvokeEndpoint operation: Received server error (500) from model with message "tensors used as indices must be long, byte or bool tensorsTraceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/sagemaker_inference/transformer.py", line 125, in transform result = self._transform_fn(self._model, input_data, content_type, accept) File "/opt/conda/lib/python3.6/site-packages/sagemaker_inference/transformer.py", line 215, in _default_transform_fn prediction = self._predict_fn(data, model) File "/opt/ml/model/code/pytorch-model-reco.py", line 268, in predict_fn return torch.argsort(- final_matrix[input_data, :], dim = 1)IndexError: tensors used as indices must be long, byte or bool tensors
1 回答

蕭十郎
TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超13個(gè)贊
線索在堆棧跟蹤的最后幾行中:
? File "/opt/ml/model/code/pytorch-model-reco.py", line 268, in predict_fn
? ? return torch.argsort(- final_matrix[input_data, :], dim = 1)
IndexError: tensors used as indices must be long, byte or bool tensors
在第 268predict_fn行中pytorch-model-reco.py,您嘗試將 用作input_data的索引final_matrix,但input_data類型錯(cuò)誤。
我猜想當(dāng)predict_fn輸入類型為 時(shí),您應(yīng)該進(jìn)行一些類型轉(zhuǎn)換text/csv。當(dāng)您的輸入類型是 numpy 數(shù)據(jù)時(shí),這種類型轉(zhuǎn)換發(fā)生在外部predict_fn。
添加回答
舉報(bào)
0/150
提交
取消