如何通过Lambda创建和执行SageMaker管道?

huangapple go评论61阅读模式
英文:

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/

huangapple
  • 本文由 发表于 2023年4月11日 12:06:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/75982324.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定