简体   繁体   English

从 S3 存储桶导入 AWS Lambda 函数代码中的库

[英]Importing libraries in AWS Lambda function code from S3 bucket

I have to deploy a Deep Learning model on AWS Lambda which does object detection.我必须在执行对象检测的 AWS Lambda 上部署深度学习模型。 It is triggered on addition of image in the S3 bucket.它在 S3 存储桶中添加图像时触发。 The issue that I'm facing is that the Lambda function code uses a lot of libraries like Tensorflow, PIL, Numpy, Matplotlib, etc. and if I try adding all of them in the function code or as layers, it exceeds the 250 MB size limit.我面临的问题是 Lambda 函数代码使用了很多库,如 Tensorflow、PIL、Numpy、Matplotlib 等,如果我尝试将它们全部添加到函数代码中或作为层,它会超过 250 MB大小限制。 Is there any way I can deploy the libraries zip file on S3 bucket and use them from there in the function code (written in Python 3.6) instead of directly having them as a part of the code?有什么方法可以在 S3 存储桶上部署库 zip 文件,并从那里在函数代码(用 Python 3.6 编写)中使用它们,而不是直接将它们作为代码的一部分? I can also try some entirely different approach for this.我也可以为此尝试一些完全不同的方法。

It sounds to me like Amazon SageMaker would be a better choice for your task.在我看来,Amazon SageMaker 是您任务的更好选择。

You can create a model and host it on an endpoint all via SageMaker.您可以通过 SageMaker 创建模型并将其托管在端点上。 The use a lambda function triggered by your s3 upload to pass the image to your SageMaker endpoint and process the result.使用 s3 上传触发的 lambda 函数将图像传递到 SageMaker 端点并处理结果。

Amazon SageMaker is a fully managed service that provides every developer and data scientist with the ability to build, train, and deploy machine learning (ML) models quickly. Amazon SageMaker 是一项完全托管的服务,可为每位开发人员和数据科学家提供快速构建、训练和部署机器学习 (ML) 模型的能力。 SageMaker removes the heavy lifting from each step of the machine learning process to make it easier to develop high quality models. SageMaker 消除了机器学习过程中每一步的繁重工作,使开发高质量模型变得更加容易。

https://aws.amazon.com/sagemaker/ https://aws.amazon.com/sagemaker/

Try out pre-compiled packs for Tensorflow, they are about 50MB, you probably would have enough space for the rest of modules you need.试试 Tensorflow 的预编译包,它们大约 50MB,你可能有足够的空间来放置你需要的其余模块。 And in general, check the AWS recommendations on deep learning architecture approaches.一般来说,请查看AWS关于深度学习架构方法的建议

Ultimately, I changed my approach from using Lambda to using EC2.最终,我将我的方法从使用 Lambda 改为使用 EC2。 I deployed the whole code with libraries on an EC2 instance and then triggered it using Lambda.我在 EC2 实例上使用库部署了整个代码,然后使用 Lambda 触发它。 On EC2, it can also be deployed on Apache server to change port mapping.在 EC2 上,它也可以部署在 Apache 服务器上以更改端口映射。

暂无
暂无

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

相关问题 创建 AWS lambda function 以在 s3 存储桶中拆分 pdf 个文件 - Creating an AWS lambda function to split pdf files in a s3 bucket 从 AWS lambda function 中的 s3 存储桶中读取 .mdb 或 .accdb 文件并使用 python 将其转换为 excel 或 csv - Reading .mdb or .accdb file from s3 bucket in AWS lambda function and converting it into excel or csv using python 根据将文件从一个 S3 存储桶复制到另一个存储桶的清单文件触发 AWS Lambda function - Trigger AWS Lambda function based on a manifest file which copies files from one S3 bucket to another 将 wordcloud plot 从 AWS lambda 保存到 S3 存储桶 - saving wordcloud plot from AWS lambda to S3 bucket 如何从 AWS Lambda 中的 s3 存储桶读取 csv 文件? - How to read csv file from s3 bucket in AWS Lambda? AWS Lambda 从 S3 存储桶中的特定文件夹中删除所有内容 - AWS Lambda to delete everything from a specific folder in an S3 bucket AWS Lambda 尝试将文件从 S3 存储桶复制到另一个 S3 存储桶时出现无效存储桶名称错误 - Invalid bucket name error when AWS Lambda tries to copy files from an S3 bucket to another S3 bucket 使用 AWS lambda function 中的 S3 存储桶中的 Pandas read_csv 时出错 - 预计第 5 行中有 1 个字段,看到 2 - Error using Pandas read_csv from S3 bucket in AWS lambda function - Expected 1 fields in line 5, saw 2 使用AWS Lambda中的Boto3将一个帐户中的S3存储桶复制到另一个帐户中的S3存储桶 - Copy from S3 bucket in one account to S3 bucket in another account using Boto3 in AWS Lambda 需要使用S3触发器编写AWS Lambda函数 - Need to code AWS lambda function with S3 triggers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM