aws sagemaker 端点的输入 json 字符串是否有限制?

Is there a limit on input json string for aws sagemaker endpoint?

我有 ~5MB json 字符串要发送到我的端点。我正在使用 boto3.client 从我的 python 客户端调用端点。它抛出 ConnectionResetError。

    File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\awsrequest.py", line 92, in _send_request
    method, url, body, headers, *args, **kwargs)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\awsrequest.py", line 119, in _send_output
    self.send(msg)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\awsrequest.py", line 203, in send
    return super(AWSConnection, self).send(str)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 977, in send
    self.sock.sendall(data)
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1012, in sendall
    v = self.send(byte_view[count:])
  File "C:\Users\corona\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 981, in send
    return self._sslobj.write(data)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

查看轨迹,我猜这是由于 json 字符串大小所致。有人可以帮我解决这个问题吗?

超过负载大小限制确实会导致 SageMaker Runtime 服务的连接重置。

来自 SageMaker documentation

Maximum payload size for endpoint invocation | 5 MB

您可以使用比 JSON 更多的 space 高效数据格式来传输负载,但可用的选项将取决于数据类型和您使用的模型图像使用(即亚马逊提供的还是自定义实现)。