英文:
how to create and execute a sagemaker pipeline via lambda?
问题
根据文档,我想要创建一个SageMaker管道,其中包括注册模型步骤(示例如下),然后通过Lambda执行它。是否有任何示例可供参考?我需要下载现有的model.tar.gz文件,重新打包并注册它。
from sagemaker.model import Model
from sagemaker.inputs import CreateModelInput
from sagemaker.workflow.steps import CreateModelStep
from sagemaker.model_metrics import MetricsSource, ModelMetrics
from sagemaker.workflow.step_collections import RegisterModel
model = Model(
image_uri=image_uri, # XGBoost镜像
model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts, # 'model.tar.gz'文件的S3位置
sagemaker_session=sagemaker_session,
role=role,
)
inputs = CreateModelInput(
instance_type="ml.m5.large",
accelerator_type="ml.eia1.medium",
)
step_create_model = CreateModelStep(
name="adultCreateModel",
model=model,
inputs=inputs,
)
step_register = RegisterModel(
name="adultRegisterModel",
estimator=xgb_train,
model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts, # 'model.tar.gz'文件的S3 URI
content_types=["text/csv"],
response_types=["text/csv"],
inference_instances=["ml.t2.medium", "ml.m5.xlarge"],
transform_instances=["ml.m5.xlarge"],
)
英文:
based on the docs, I want to create a sagemaker pipeline with register model step ( sample below) and execute it via lambda. are there any examples. i need to download the existing model.tar.gz file and repackage and register it .
from sagemaker.model import Model
from sagemaker.inputs import CreateModelInput
from sagemaker.workflow.steps import CreateModelStep
from sagemaker.model_metrics import MetricsSource, ModelMetrics
from sagemaker.workflow.step_collections import RegisterModel
model = Model(
image_uri=image_uri, # the XGBoost image
model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts, # The S3 location of the 'model.tar.gz' file
sagemaker_session=sagemaker_session,
role=role,
)
inputs = CreateModelInput(
instance_type="ml.m5.large",
accelerator_type="ml.eia1.medium",
)
step_create_model = CreateModelStep(
name="adultCreateModel",
model=model,
inputs=inputs,
)
step_register = RegisterModel(
name="adultRegisterModel",
estimator=xgb_train,
model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts, # The S3 uri to the 'model.tar.gz' file
content_types=["text/csv"],
response_types=["text/csv"],
inference_instances=["ml.t2.medium", "ml.m5.xlarge"],
transform_instances=["ml.m5.xlarge"],
)
答案1
得分: 1
请参考此博客,了解如何使用Lambda创建SageMaker Pipeline - https://aws.amazon.com/blogs/machine-learning/use-a-sagemaker-pipeline-lambda-step-for-lightweight-model-deployments/
英文:
Please refer to this blog for guidance on creating a SageMaker Pipeline using Lambda - https://aws.amazon.com/blogs/machine-learning/use-a-sagemaker-pipeline-lambda-step-for-lightweight-model-deployments/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论