如何使用AWS Lambda部署大型python软件包?
我需要一些建议.
我使用Tensorflow训练了图像分类器,并希望使用 serverless 将其部署到AWS Lambda.该目录包括模型,一些python模块(包括tensorflow和numpy)以及python代码.解压缩之前,完整文件夹的大小为340 MB,AWS lambda拒绝了该文件夹,并显示一条错误消息"The unzipped state must be smaller than 262144000 bytes"
.
I trained an image classifier using Tensorflow and wanted to deploy it to AWS Lambda using serverless. The directory includes the model, some python modules including tensorflow and numpy, and python code. The size of the complete folder before unzipping is 340 MB, which gets rejected by AWS lambda with an error message saying "The unzipped state must be smaller than 262144000 bytes"
.
我应该如何处理?我不能在AWS Lambda上部署此类软件包吗?
How should I approach this? Can I not deploy packages like these on AWS Lambda?
注意:在requirements.txt文件中,列出了2个模块,包括numpy和tensorflow. (Tensorflow是一个很大的模块)
Note: In the requirements.txt file, there are 2 modules listed including numpy and tensorflow. (Tensorflow is a big module)
我知道我回答得很晚..只是把它放在这里供其他人参考. 我做了以下事情-
I know I am answering it very late .. just putting it here for reference for other people.. I did the following things -
- 根据建议删除/external/*/tensorflow/contrib/*/tensorflow/include/unsupported/*文件此处.
- Delete /external/* /tensorflow/contrib/* /tensorflow/include/unsupported/* files as suggested here.
- Strip all .so files especially two files in site-packages/numpy/core - _multiarray_umath.cpython-36m-x86_64-linux-gnu.so and _multiarray_tests.cpython-36m-x86_64-linux-gnu.so. Strip considerably reduces their size.
- You can put your model in S3 bucket and download it at runtime. This will reduce the size of the zip. This is explained in detail here.
如果这不起作用,则可以执行一些其他操作,例如删除pyc文件等,如所述
If this does not work then there are some additional things that can be done like removing pyc files etc as mentioned here