翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
Amazon SageMaker Debugger Python モジュールを使用して基本的なプロファイリングのパラメータを使用して推定器を設定する
デフォルトでは、 SageMaker デバッガーの基本プロファイリングはデフォルトでオンになっており、Amazon SageMaker Python SDK を使用して送信されたすべての SageMaker トレーニングジョブの CPU 使用率、GPU 使用率、GPU メモリ使用率、ネットワーク、I/O 待機時間などのリソース使用率メトリクスをモニタリングします。 SageMaker デバッガーは 500 ミリ秒ごとにこれらのリソース使用率メトリクスを収集します。基本的なリソース使用率を追跡するために、コード、トレーニングスクリプト、またはジョブランチャーに追加の変更を加える必要はありません。 SageMaker Studio でトレーニングジョブのリソース使用率メトリクスダッシュボードにアクセスする場合は、 にジャンプできますAmazon SageMaker Studio Classic Experiments の Amazon SageMaker デバッガー UI。
基本プロファイリングのメトリクス収集間隔を変更する場合は、 SageMaker Python SDK、または AWS Command Line Interface (CLI) を使用して SageMaker トレーニングジョブランチャーを作成するときに AWS SDK for Python (Boto3)、デバッガー固有のパラメータを指定できます。このガイドでは、Amazon SageMaker Python SDK を使用してプロファイリングオプションを変更する方法に焦点を当てます。
システムリソースの使用率の問題を自動的に検出するルールをアクティブ化する場合は、ルールをアクティブ化する rules
パラメータを推定器オブジェクトに追加できます。
最新の SageMaker デバッガー機能を使用するには、 SageMaker Python SDK とSMDebug
クライアントライブラリをアップグレードする必要があります。iPython カーネル、Jupyter Notebook、または JupyterLab 環境で、次のコードを実行して最新バージョンのライブラリをインストールし、カーネルを再起動します。
import sys
import IPython
!{sys.executable} -m pip install -U sagemaker smdebug
IPython.Application.instance().kernel.do_shutdown(True)
Python SDK の SageMaker デバッガー Python モジュール SageMakerで SageMaker 推定器オブジェクトを設定するためのコードテンプレート
基本的なプロファイリング設定 (profiler_config
) を調整するか、プロファイラールール (rules
) を追加するには、いずれかのタブを選択して SageMaker 推定器を設定するためのテンプレートを取得します。以降のページでは、2 つのパラメータの設定方法について詳細を示します。
次のコード例は、直接実行できません。次のセクションに進み、各パラメータの設定方法について説明します。
- PyTorch
-
# An example of constructing a SageMaker PyTorch estimator
import boto3
import sagemaker
from sagemaker.pytorch import PyTorch
from sagemaker.debugger import ProfilerConfig, ProfilerRule, rule_configs
session=boto3.session.Session()
region=session.region_name
profiler_config
=ProfilerConfig(...)
rules
=[
ProfilerRule.sagemaker(rule_configs.BuiltInRule())
]
estimator=PyTorch(
entry_point="directory/to/your_training_script.py
",
role=sagemaker.get_execution_role(),
base_job_name="debugger-profiling-demo
",
instance_count=1
,
instance_type="ml.p3.2xlarge
",
framework_version="1.12.0
",
py_version="py37
",
# SageMaker Debugger parameters
profiler_config=profiler_config
,
rules=rules
)
estimator.fit(wait=False)
- TensorFlow
-
# An example of constructing a SageMaker TensorFlow estimator
import boto3
import sagemaker
from sagemaker.tensorflow import TensorFlow
from sagemaker.debugger import ProfilerConfig, ProfilerRule, rule_configs
session=boto3.session.Session()
region=session.region_name
profiler_config
=ProfilerConfig(...)
rules
=[
ProfilerRule.sagemaker(rule_configs.BuiltInRule())
]
estimator=TensorFlow(
entry_point="directory/to/your_training_script.py
",
role=sagemaker.get_execution_role(),
base_job_name="debugger-profiling-demo
",
instance_count=1
,
instance_type="ml.p3.2xlarge
",
framework_version="2.8.0
",
py_version="py37
",
# SageMaker Debugger parameters
profiler_config=profiler_config
,
rules=rules
)
estimator.fit(wait=False)
- MXNet
-
# An example of constructing a SageMaker MXNet estimator
import sagemaker
from sagemaker.mxnet import MXNet
from sagemaker.debugger import ProfilerConfig, ProfilerRule, rule_configs
profiler_config
=ProfilerConfig(...)
rules
=[
ProfilerRule.sagemaker(rule_configs.BuiltInRule())
]
estimator=MXNet(
entry_point="directory/to/your_training_script.py
",
role=sagemaker.get_execution_role(),
base_job_name="debugger-profiling-demo
",
instance_count=1
,
instance_type="ml.p3.2xlarge
",
framework_version="1.7.0
",
py_version="py37
",
# SageMaker Debugger parameters
profiler_config=profiler_config
,
rules=rules
)
estimator.fit(wait=False)
MXNet の場合、profiler_config
パラメータを設定するときは、システムモニタリング用にのみ設定できます。MXNet では、フレームワークメトリクスのプロファイリングはサポートされていません。
- XGBoost
-
# An example of constructing a SageMaker XGBoost estimator
import sagemaker
from sagemaker.xgboost.estimator import XGBoost
from sagemaker.debugger import ProfilerConfig, ProfilerRule, rule_configs
profiler_config
=ProfilerConfig(...)
rules
=[
ProfilerRule.sagemaker(rule_configs.BuiltInRule())
]
estimator=XGBoost(
entry_point="directory/to/your_training_script.py
",
role=sagemaker.get_execution_role(),
base_job_name="debugger-profiling-demo
",
instance_count=1
,
instance_type="ml.p3.2xlarge
",
framework_version="1.5-1
",
# Debugger-specific parameters
profiler_config=profiler_config
,
rules=rules
)
estimator.fit(wait=False)
XGBoost の場合、profiler_config
パラメータを設定するときは、システムモニタリング用にのみ設定できます。XGBoost では、フレームワークメトリクスのプロファイリングはサポートされていません。
- Generic estimator
-
# An example of constructing a SageMaker generic estimator using the XGBoost algorithm base image
import boto3
import sagemaker
from sagemaker.estimator import Estimator
from sagemaker import image_uris
from sagemaker.debugger import ProfilerConfig, DebuggerHookConfig, Rule, ProfilerRule, rule_configs
profiler_config
=ProfilerConfig(...)
rules
=[
ProfilerRule.sagemaker(rule_configs.BuiltInRule())
]
region=boto3.Session().region_name
xgboost_container=sagemaker.image_uris.retrieve("xgboost", region, "1.5-1")
estimator=Estimator(
role=sagemaker.get_execution_role()
image_uri=xgboost_container,
base_job_name="debugger-demo
",
instance_count=1
,
instance_type="ml.m5.2xlarge
",
# Debugger-specific parameters
profiler_config=profiler_config
,
rules=rules
)
estimator.fit(wait=False)
次に、パラメータについて簡単に説明します。
デバッガーは、デフォルトの S3 バケットのサブフォルダに出力データを安全に保存します。例えば、デフォルトの S3 バケット URI の形式は、s3://sagemaker-<region>-<12digit_account_id>/<base-job-name>/<debugger-subfolders>/
です。デバッガーによって作成されるサブフォルダは、debug-output
、profiler-output
、rule-output
の 3 つです。SageMaker 推定器クラスメソッド を使用して、デフォルトの S3 バケット URIs を取得することもできます。
デバッガー固有パラメータの詳細な設定方法については、次のトピックを参照してください。