如何在没有 lambda 的情况下访问/调用 sagemaker 端点?
根据 aws 文档,api 网关中的最大超时限制小于 30 秒。因此,如果请求/响应需要超过 30 秒,则将 sagemaker 端点与 api 网关连接起来就没有意义。有什么解决方法吗?在 api 网关和 sagemaker 端点之间添加 lambda 将增加更多时间来处理请求/响应,这是我想避免的。此外,还会增加 lambda 冷启动时间,并且 sagemaker 无服务器端点构建在 lambda 之上,因此也会增加冷启动时间。有没有一种方法可以调用无服务器 sagemaker 端点,而无需这些开销?
based on the aws documentation, maximum timeout limit is less that 30 seconds in api gateway.so hooking up an sagemaker endpoint with api gateway wouldn't make sense, if the request/response is going to take more than 30 seconds. is there any workaround ? adding a lambda in between api gateway and sagemaker endpoint is going to add more time to process request/response, which i would like to avoid. also, there will be added time for lambda cold starts and sagemaker serverless endpoints are built on top of lambda so that will also add cold start time. is there a way to invoke the serverless sagemaker endpoints , without these overhead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确实可以在不使用任何其他 AWS 服务的情况下从 sagemaker 调用 sagemaker 端点,并且它们具有调用 URL 这一事实也证明了这一点。
设置方法如下:
您可以将
替换为*
让该用户调用所有端点。使用 ACCESS-KEY 和 SECRET-ACCESS-KEY 在邮递员中配置授权,如此屏幕截图所示。还可以在高级选项卡中添加参数,如屏幕截图所示。
然后用相关的内容类型填写您的正文。
然后添加或删除其他标头,例如变体名称或型号名称(如果您已设置它们)并且标头应如下屏幕截图所示:
发送请求以接收回复,例如这
上面屏幕截图中的 URL 和凭据不再起作用,废话!
如果您希望代码使用某些返回值直接调用端点-结束语言,这里是 python 代码。
It is indeed possible to invoke sagemaker endpoints from sagemaker without using any other AWS services and that is also manifested by the fact that they have invocation URLs.
Here's how you set it up:
you can replace
<endpoint-name>
with*
to let this user invoke all endpoints.use the ACCESS-KEY and SECRET-ACCESS-KEY to configure authorisation in postman like shown in this screenshot. also add the parameters in advanced tab like shown in the screenshot.
then fill up your body with the relevant content type.
then add or remove additional headers like variant-name or model-name, if you have them set up and the headers should look like shown in this screenshot:
send the request to receive reponse like this
URL and credentials in the above screenshots doesn't work anymore, duh!
and if you want code to invoke the endpoint directly using some back-end language, here's code for python.
您可以使用映射模板将 SageMaker 端点直接连接到 API Gateway,无需中间 Lambda,https://aws.amazon.com/fr/blogs/machine-learning/creating-a-machine-learning-powered-rest-api-with-amazon-api-gateway-mapping-templates-and-amazon -sagemaker/
您还可以使用AWS SDK调用终端节点(例如CLI,boto3),不一定需要为 API GW 执行此操作。
You can connect SageMaker endpoints to API Gateway directly, without intermediary Lambdas, using mapping templates https://aws.amazon.com/fr/blogs/machine-learning/creating-a-machine-learning-powered-rest-api-with-amazon-api-gateway-mapping-templates-and-amazon-sagemaker/
You can also invoke endpoints with AWS SDKs (eg CLI, boto3), no need to do it for API GW necessarily.