简体   繁体   English

在python中为AWS Lambda构建TensorFlow包

[英]Building TensorFlow package for AWS Lambda in python

https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html#python-package-dependencies https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html#python-package-dependencies

Above link helps to build a deployment package for AWS-Lambda. 以上链接有助于为AWS-Lambda构建部署包。 I am planning to build a package to access TensorFlow. 我打算构建一个包来访问TensorFlow。 After following the steps from AWS documentation zip file is around 110MB and directory size is 330MB. 遵循AWS文档中的步骤后,zip文件大约为110MB,目录大小为330MB。

By using the below commands package size can be reduced: 通过使用以下命令,可以减小包大小:

find -name "*.so" | xargs strip

find -name "*.so*" |xargs strip

find . -name \\*pyc -delete

rm -R wheel*

find . -type d -name "tests" -exec rm -rf {} +

Zip package size will be reduced to 90MB and directory size is around 290MB which is still greater than the threshold mentioned by AWS. Zip包大小将减少到90MB,目录大小约为290MB,仍然大于AWS提到的阈值。

I also tried to use the docker to build AWS-Lambda package but, Again size was more than the AWS limit. 我还尝试使用docker来构建AWS-Lambda包,但是,再次大小超过AWS限制。 https://medium.com/i-like-big-data-and-i-cannot-lie/how-to-create-an-aws-lambda-python-3-6-deployment-package-using-docker-d0e847207dd6 https://medium.com/i-like-big-data-and-i-cannot-lie/how-to-create-an-aws-lambda-python-3-6-deployment-package-using-docker- d0e847207dd6

Does anyone have any suggestions/opinions where to find the correct documentation to build the package within the AWS size limit? 有没有人有任何建议/意见在哪里可以找到正确的文档来构建AWS大小限制内的包?

Don't build large dependencies into your lambda function. 不要在lambda函数中构建大的依赖项。 Use lambda layers to carry heavy dependencies. 使用lambda图层来承载重度依赖关系。 Lots of examples for this now. 现在有很多例子。 eg., https://github.com/antonpaquin/Tensorflow-Lambda-Layer 例如, https://github.com/antonpaquin/Tensorflow-Lambda-Layer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM