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?
- 1Why would you want to use Tensorflow with AWS Lambda? Seems like that is not the way to goBlokje5– Blokje52020-01-15 09:17:05 +00:00Commented Jan 15, 2020 at 9:17
- 1I am using tensorflow with AWS lambda as AWS Lambda is very cheap.Debangshu Paul– Debangshu Paul2020-01-15 13:58:50 +00:00Commented Jan 15, 2020 at 13:58
- Yeah, but you are training a machine learning model (I assume at least). Lambda has a 15 minute runtime max. Machine learning can take hours even days to train (depending on your data size). If you want to do machine learning, Lambdas really are not the way to go. I would look into AWS SageMakerBlokje5– Blokje52020-01-15 14:00:50 +00:00Commented Jan 15, 2020 at 14:00
- 4I am not training I am doing the predictions.Debangshu Paul– Debangshu Paul2020-01-15 14:39:14 +00:00Commented Jan 15, 2020 at 14:39
- @DebangshuPaul have you found a solution on this issue?Mpizos Dimitris– Mpizos Dimitris2020-11-23 09:20:51 +00:00Commented Nov 23, 2020 at 9:20
5 Answers
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.
2 Comments
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
Comments
As of March 2021, the best solution is probably to use a container image for the Lambda as explained here.
Comments
There are serevarl options in order to deploy Tensorflow in AWS lambda:
Comments
I've been able to use Tensorflow on Lambda by deploying the function with a Docker image. See this post

