Skip to content

alexeybutyrev/aws_lambda_xgboost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws_lambda_xgboost

AWS Lambda Deployment Xgboost package Python 3.6

Description

We all know with AWS Lambda 50Mb limit on zip upload and ~262Mb limit from AWS s3 unzipped total size. This script allows you to make a package that will have xgboost library with all the dependencies and joblib.

Notes

  • The final size is of the file in the zip is about 254M which leaves you about 8M for extra files and packages
  • In most cases it's imposible to zip your models into the rest of 8Mb in the zip file (262 - 254) so here there a solotion with boto3 library how to load models from s3 buckets
  • The model load call should be before lambda_function that's how it would be loaded once and not going to waste time in calls
  • In the code it's suggested to load model into local AWS Lambda /tmp/ directory. That directory is limited to 500Mb

How to Install/Run

  1. Clone this repo to your local folder

  2. Run this command from the repo folder

docker run -v $(pwd):/outputs -it amazonlinux:2016.09 /bin/bash /outputs/build.sh
  1. There will be generated folder lambda-package and the zip file lambda-package.zip

  2. Edit file lambda_function.py to adopt it to your models

  3. Add it to lambda-package.zip file

  4. Upload lambda-package.zip into AWS s3 bucket

  5. Set up up PATH in the AWS Lambda, Python 3.6 as Runtime, Increase memory in base settings

  6. Create Test

  7. Save

  8. Test

  9. Repeat until it works :)

Credits

Ryan Brown for providing original packaging sklearn and numpy example Here it was used modified version to Python 3.6 from Mark Campanelli

Jing Xie and Ken Mcdonnell for helping with deploying models and debugging.

About

AWS Lambda Deployment Xgboost package

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published