本文介绍了借助AWS SageMaker,是否可以使用sagemaker SDK部署预训练的模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图避免将现有的模型训练过程迁移到SageMaker,并避免创建自定义Docker容器来承载我们的训练模型.

I'm trying to avoid migrating an existing model training process to SageMaker and avoid creating a custom Docker container to host our trained model.

我希望将我们现有的,经过训练的模型注入AWS通过 sagemaker-python-sdk .我发现的所有示例都需要先训练模型,然后再在SageMaker中创建模型/模型配置.然后使用 deploy 方法进行部署.

My hope was to inject our existing, trained model into the pre-built scikit learn container that AWS provides via the sagemaker-python-sdk. All of the examples that I have found require training the model first which creates the model/model configuration in SageMaker. This is then deployed with the deploy method.

是否可以为 deploy 方法提供经过训练的模型,并将其托管在AWS提供的预先构建的scikit学习容器中?

Is it possible to provide a trained model to the deploy method and have it hosted in the pre-built scikit learn container that AWS provides?

作为参考,示例我已经看到遵循以下操作顺序:

For reference, the examples I've seen follow this order of operations:

  1. 创建 sagemaker.sklearn.estimator.SKLearn 的实例并提供训练脚本
  2. 在其上调用 fit 方法
  3. 这将在SageMaker中创建模型/模型配置
  4. SKLearn 实例上调用 deploy 方法,该方法自动获取在第2/3步中创建的模型,并将其作为HTTPS部署在预构建的scikit Learn容器中端点.
  1. Creating an instance of sagemaker.sklearn.estimator.SKLearn and providing a training script
  2. Call the fit method on it
  3. This creates the model/model configuration in SageMaker
  4. Call the deploy method on the SKLearn instance which automagically takes the model created in step 2/3 and deploys it in the pre-build scikit learn container as an HTTPS endpoint.

推荐答案

是的,您可以将现有模型导入SageMaker.

Yes, you can import existing models to SageMaker.

对于scikit-learn,您可以使用SKLearnModel()对象从S3加载模型并在SageMaker中创建它.然后,您可以像往常一样部署它.

For scikit-learn, you would use the SKLearnModel() object to load to model from S3 and create it in SageMaker. Then, you could deploy it as usual.

https://sagemaker.readthedocs.io/en/latest/sagemaker.sklearn.html

这是一个基于MXNet的完整示例,它将为您指明正确的方向: https://github.com/awslabs/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/mxnet_onnx_superresolution/mxnet_onnx.ipynb

Here's a full example based on MXNet that will point you in the right direction:https://github.com/awslabs/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/mxnet_onnx_superresolution/mxnet_onnx.ipynb

这篇关于借助AWS SageMaker,是否可以使用sagemaker SDK部署预训练的模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 05:41