amazon-sagemaker-examples icon indicating copy to clipboard operation
amazon-sagemaker-examples copied to clipboard

invoke endpoint fail

Open RileyJia opened this issue 8 years ago • 11 comments

Hi Sagemaker Community,

I am a starter for using Sagemaker. Right now I want to invoke a endpoint to reload a model using Python, but I am a little confused about what should set for "Body". I am using the example code of linear learner on mnist.

And here is my reload code:

import boto3
import json
sagemaker = boto3.client('runtime.sagemaker')
result = sagemaker.invoke_endpoint(
    EndpointName='linear-learner-2018-07-13-06-01-55-399',
    Body = json.dumps(test_set[0].tolist())
)

I got an error: ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

I don't know what cause that and how to fix it. Can you help me with it?

RileyJia avatar Jul 16 '18 06:07 RileyJia

Hi @Rulovescoding

  1. It looks like your payload is the entire MNIST test set. Can you try sending a smaller payload (maybe just a single record) instead?
  2. Also, can you specify ContentType='application/json' in your invoke_endpoint() call? Thanks.

djarpin avatar Jul 25 '18 22:07 djarpin

Closing due to inactivity. Feel free to re-open if necessary. Thanks.

djarpin avatar Aug 17 '18 16:08 djarpin

Hi everybody! I'm having the same problem with the predict() method of a SM predictor. I'm sending however just one sample at a time so I cannot further reduce the payload. The problem in particular appears when my NN must process a large sample which requires some time to be analyzed. Any intuition on how to solve this? It mostly seems a timeout problem.

Thanks!

fmonti avatar Aug 31 '18 09:08 fmonti

Same problem here! Did anyone figure out the cause? (seems like timeout to me as well)

gautiese avatar Oct 29 '18 08:10 gautiese

I have the same problem too

eyalgaon84 avatar Oct 29 '18 13:10 eyalgaon84

Hi @fmonti , @gautiese , and @eyalgaon84 . SageMaker has several limits on inference requests. If your payload size for a single record is over 5MB or inference processing is longer than 60 seconds then passing in an S3 input (and output) path and having the container read from and write to S3 directly is probably the easiest way to work around these.

djarpin avatar Oct 29 '18 15:10 djarpin

Thanks for this! I didnt see the 5MB limit anywhere, Im sure thats whats tripping my endpoint.

gautiese avatar Oct 30 '18 02:10 gautiese

payload size for a single record is over 5MB

This limit has recently been removed from the InvokeEndpoint API and most of the containers provided by SageMaker.

jesterhazy avatar Nov 02 '18 00:11 jesterhazy

@jesterhazy How is the limit imposed? I think I'm running into it building a BYO model on top of sagemaker-tensorflow-serving-container. Attempting to modify client_max_body_size in nginx.conf did not help.

austinmw avatar Jan 18 '19 22:01 austinmw

@jesterhazy @austinmw

Running into the same problem of BYO Docker image. In my nginx.conf, I set client_max_body_size 100M; and the Docker image works fine locally. However, when I deploy the Docker on a Sagemaker endpoint via ECR, it throws ConnectionResetError: [Erro 104] Connection reset by peer.

My JSON string has 5721461 characters/bytes. It's a standard size 1x299x299x3 image array.

The endpoint works fine if I throw a small bogus payload.

Where and how can I change the InvokeEndpoint API payload size limit?

leehanchung avatar Dec 20 '19 07:12 leehanchung

@djarpin Could you please have a look at

https://forums.aws.amazon.com/message.jspa?messageID=927004#927004

I am facing similar issue. Let know if you require additional details.

Also, I am not able to find any sample request format for linear-learner to use in boto3/invoke_endpoint. However, I can make successfull inference call inside sagemaker notebook instance.

nmakarun avatar Dec 23 '19 16:12 nmakarun