A hands on tutorial on Docker and AWS Lambda for Machine Learning applications.
Videos and slides: http://hi.cs.stonybrook.edu/teaching/docker4ml
Using the scripts
Dockerfile.ultimate_mlto build a container with your favorite ML framework.
- Build a model you'd like to serve in the cloud. You can follow the script in
Serverless-ML-API-example.ipynbto build an MNIST classifier with
XGBoost. Pickle the model to a file.
Dockerfile.aws_ami_for_lambdato reflect a python execution environment for AWS Lambda that can run your model (e.g. if you used XGBoost you'd want XGBoost installed)
docker_build_lambda_env.shto build the AWS Linux container and extract the packaged virtual environment files (
lambda_function.pyto perform the prediction on your model depending on the inputs and outputs you expect (e.g. input MNIST digit pixels in a JSON array and output the predicted digit)
- Create a Lambda function on AWS, give it a unique name.
- Create an S3 bucket on AWS, give it a unique name.
lambda_config.pywith the names of the function, S3 bucket, region, etc.
add_lambda_and_upload.shto upload the Lambda code, environment and ML model to S3 and then deploy everything to your lambda function.
- Optionally create an AWS API Gateway to trigger the Lambda function on an HTTP request.