Is it possible to deploy a scikit-learn model to a SageMaker serverless endpoint?

0

I have trained a Scikit-Learn model within a SageMaker Training job and uploaded the model.tar.gz. file to S3. Now I would like to deploy this model as a serverless endpoint but I am getting the well-known error due to image size limitations of Lambda: "Image size 10771903611 is greater than supported size 10737418240" I am using image 492215442770.dkr.ecr.eu-central-1.amazonaws.com/sagemaker-scikit-learn:1.2-1-cpu-py3, whose size when pulled locally is 5.7GB (as output by docker ls command). Is there an sklearn image suitable for serverless deployment?

Thanks, Nikos

Nikos
asked a month ago66 views
2 Answers
0
Accepted Answer

Hello Nikos,

If possible please try to build the image from official image and try with further reduced image size for deploying on serverless inference. You can exclude lines from L90-L116 in the base image to reduce the size further and use the custom built final image to deploy the serverless inference endpoint. The steps for building the image are here.

AWS
answered a month ago
profile picture
EXPERT
reviewed 6 days ago
  • Thanks, I will try it when I find some time. I didn't know about mlio. Shall I miss some functionality during inference if I ommit those lines?

  • Well I tried to build locally but ran into many errors. Shouldn't there exist a ready-to-use sklearn image for serverless deployment? Or otherwise be mentioned in the documentation that serverless endpoints are not supported with sagemaker-scikit-learn-container ?

  • Hello Nikos,

    MLIO is package useful specially during the training. In your case for inference this might not be required.

    Regarding the errors during the docker build, can you test this on linux machine if not already tried?. In my local testing I found that the build fails on mac/windows systems.

    "Shouldn't there exist a ready-to-use Sklearn image for serverless deployment?" - Yes there are ready to use Sagemaker images with Sklearn, but during my testing it was found out that smaller docker images seems to be working with out any issues for Serverless inference.

    If you face further issues I would suggest reaching out to AWS Support.

  • Hi,

    thank you, indeed, I was able to deploy to a serverless endpoint using image 492215442770.dkr.ecr.eu-central-1.amazonaws.com/sagemaker-scikit-learn:1.0-1-cpu-py3. But the scikit-learn package version in this image is 1.0.2 which is too old (December 2021).

-1

Hi,

See part 5 of https://tutorialsdojo.com/train-and-deploy-a-scikit-learn-model-in-amazon-sagemaker/

It explains how to deploy a model trained with scikit-lean on AWS SageMaker

Best,

Didier

profile pictureAWS
EXPERT
answered a month ago
  • Thank you, but this doesn't answer my question. I specifically asked about a serverless endpoint. I know how to create a real-time endpoint like described in the link you provided.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions