7

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?

6
  • 1
    Why would you want to use Tensorflow with AWS Lambda? Seems like that is not the way to go Commented Jan 15, 2020 at 9:17
  • 1
    I am using tensorflow with AWS lambda as AWS Lambda is very cheap. Commented 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 SageMaker Commented Jan 15, 2020 at 14:00
  • 4
    I am not training I am doing the predictions. Commented Jan 15, 2020 at 14:39
  • @DebangshuPaul have you found a solution on this issue? Commented Nov 23, 2020 at 9:20

5 Answers 5

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes but that storage is not permanent right, I already tried downloading from s3 to the /tmp folder and it seems everytime I have to do it which is very inefficient in terms of cost and performance. is there any other way to do this?
Use the EFS and load your models from there to overcome the MB limit.
1

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

1

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

Comments

0

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

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.