翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
ローカルモードを使用してパイプラインを実行する
SageMaker Pipelines のローカルモードを使用すると、マネージド SageMaker AI サービスでパイプラインを実行する前に、トレーニング、処理、推論スクリプトや、パイプラインパラメータ
パイプラインのローカルモードは、内部で SageMaker ジョブのローカルモード
パイプラインローカルモードは現在、以下のステップタイプをサポートしています。
並列処理設定
注記
パイプラインのローカルモードは、XGBoost などの SageMaker AI アルゴリズムとは互換性がありません。これらのアルゴリズムを使用する場合は、スクリプトモード
パイプラインをローカルで実行するには、パイプラインステップとパイプライン自体に関連付けられた sagemaker_session フィールドが LocalPipelineSession 型と一致している必要があります。次の例は、ローカルで実行される SageMaker AI パイプラインを定義する方法を示しています。
from sagemaker.core.workflow.pipeline_context import LocalPipelineSession from sagemaker.train import ModelTrainer from sagemaker.train.configs import InputData, SourceCode from sagemaker.train.configs import Compute from sagemaker.mlops.workflow.steps import TrainingStep from sagemaker.mlops.workflow.pipeline import Pipeline from sagemaker.core.helper.session_helper import get_execution_role from sagemaker.core import image_uris local_pipeline_session = LocalPipelineSession() training_image = image_uris.retrieve( framework="pytorch", region=region, version="1.8.0", py_version="py36", instance_type="ml.c5.xlarge", image_scope="training" ) pytorch_model_trainer = ModelTrainer( role=get_execution_role(), compute=Compute( instance_type="ml.c5.xlarge", instance_count=1, ), training_image=training_image, source_code=SourceCode(entry_script="./entry_point.py"), ) step = TrainingStep( name="MyTrainingStep", step_args=pytorch_model_trainer.train( input_data_config=[InputData(channel_name="training", data_source="s3://amzn-s3-demo-bucket/my-data/train")], ) ) pipeline = Pipeline( name="MyPipeline", steps=[step], sagemaker_session=local_pipeline_session ) pipeline.create( role_arn=get_execution_role(), description="local pipeline example" ) # pipeline will execute locally execution = pipeline.start() steps = execution.list_steps() training_job_name = steps['PipelineExecutionSteps'][0]['Metadata']['TrainingJob']['Arn'] step_outputs = local_pipeline_session.sagemaker_client.describe_training_job(TrainingJobName = training_job_name)
SageMaker Pipelines マネージドサービスでパイプラインを実行する準備ができたら、前のコードスニペットの LocalPipelineSession を (次のコードサンプルに示すように) PipelineSession に置き換え、コードを再実行することでパイプラインを実行できます。
from sagemaker.workflow.pipeline_context import PipelineSession pipeline_session = PipelineSession()