Skip to content

Instantly share code, notes, and snippets.

@mattmcd
Created March 20, 2018 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmcd/e60116fddd0e963577bd284680e7e589 to your computer and use it in GitHub Desktop.
Save mattmcd/e60116fddd0e963577bd284680e7e589 to your computer and use it in GitHub Desktop.
TensorFlow library install on AmazonLinux for AWS Lambda
FROM amazonlinux:latest
MAINTAINER Matt McDonnell "matt@matt-mcdonnell.com"
RUN yum -y -q update
RUN yum -y -q install python27-pip zip
RUN pip install -q virtualenv
RUN virtualenv tf_env
RUN source tf_env/bin/activate && \
pip install -q --upgrade --ignore-installed https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl && \
pip install -q pillow
RUN touch tf_env/lib/python2.7/site-packages/google/__init__.py
RUN cd tf_env/lib/python2.7/site-packages/ && zip -qr ~/tf_env.zip . --exclude \*.DS_Store \*.pyc /external/\* /tensorflow/contrib/\* /tensorflow/include/unsupported/\*
CMD cp ~/tf_env.zip /app/
@mattmcd
Copy link
Author

mattmcd commented Mar 20, 2018

Used to create a zip file containing numpy, tensorflow, pillow compiled on amazonlinux Docker image (same as AWS Lambda runtime environement).

Can then just run the container with shared volume to host to produce the necessary set of libraries to include in AWS Lambda zipfile
docker run --rm --mount type=bind,source=/home/mattmcd/build_tf_lambda/vendored,target=/app mattmcd/tensorflow_lambda:0.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment