'How to use tensorflow 2.0 with AWS Lambda?

I am new to AWS Lambda and running a tensorflow model in AWS Lambda. Now tensorflow 1.0.0 is the one that fits into the 50Mb limit but since tensorflow 2.0 is much bigger in size it does not fit. Does anyone knows of a way to use tensorflow 2.0 with AWS lambda?



Solution 1:[1]

AWS Lambda comes with an ephemeral storage unit in /tmp. However, please note that the ephemeral storage unit still has a storage of 512MB. You can load your dependencies to this storage, and write code accordingly.

Solution 2:[2]

One of the variant is using EFS.
Run EC2 instance, mount EFS and install Tensorflow or any other library on it.
Then in lambda function you can select file system with installed libraries and import them in your function.
You can use AWS official documentation or try those tutorials.
For me it helps and i was able to import tensorflow in my lambda function.
How to use EFS (Elastic File System) with AWS Lambda: https://youtu.be/4cquiuAQBco
How to mount EFS on EC2 instance: https://youtu.be/PHVthx8lG4g
How to install library on EFS & import in lambda: https://youtu.be/FA153BGOV_A

Solution 3:[3]

As of March 2021, the best solution is probably to use a container image for the Lambda as explained here.

Solution 4:[4]

There are serevarl options in order to deploy Tensorflow in AWS lambda:

  1. With Amazon EFS:

enter image description here

  1. Using AWS container images

enter image description here

  1. AWS Lambda using Serverless

  2. With AWS serverless and Tensorflow Lite

Solution 5:[5]

I've been able to use Tensorflow on Lambda by deploying the function with a Docker image. See this post

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arka Mukherjee
Solution 2 jhenya-d
Solution 3 Franco Piccolo
Solution 4 Rene B.
Solution 5 Wesley Cheek