Docker4MLTutorial
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
General sequence:
- Use
Dockerfile.ultimate_ml
to 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.ipynb
to build an MNIST classifier withsklearn
andXGBoost
. Pickle the model to a file. - Modify
Dockerfile.aws_ami_for_lambda
to reflect a python execution environment for AWS Lambda that can run your model (e.g. if you used XGBoost you'd want XGBoost installed) - Use
docker_build_lambda_env.sh
to build the AWS Linux container and extract the packaged virtual environment files (venv*.zip
) - Modify
lambda_function.py
to 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.
- Modify
lambda_config.py
with the names of the function, S3 bucket, region, etc. - Use
add_lambda_and_upload.sh
to 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.