0

托管 Spot 培训:在您的 Amazon SageMaker 培训作业上节省高达 90%说:

设置它非常简单,就像在使用完全托管的服务时一样:

  • 如果您使用的是控制台,只需打开该功能即可。
  • 如果您使用的是 Amazon SageMaker 开发工具包,只需在 Estimator 构造函数中将 train_use_spot_instances 设置为 true

SageMaker SDK sagemaker.estimator.Estimator说:

  • use_spot_instances (bool) – 指定是否使用 SageMaker Managed Spot 实例进行训练。如果启用,则还应设置 max_wait 参数。
  • max_wait (int) -- 等待现场训练实例的超时(以秒为单位)(默认值:无)。在这段时间之后,Amazon SageMaker 将停止等待 Spot 实例可用(默认值:无)。

根据文档,在下面运行。

from sagemaker.tensorflow import TensorFlow


estimator = TensorFlow(
    entry_point="fashion_mnist_training.py",
    source_dir="src",
    metric_definitions=metric_definitions,
    hyperparameters=hyperparameters,
    role=role,
    input_mode='File',
    framework_version="2.3.1",
    py_version="py37",
    instance_count=1,
    instance_type="ml.m5.xlarge",
    use_spot_instances=True,
    max_wait= 23 * 60 * 60, 
    base_job_name=base_job_name,
    checkpoint_s3_uri=checkpoint_s3_uri,
    model_dir=False  # To avoid duplicate 'model_dir' command line argument
)

但是,会导致错误。

ClientError: An error occurred (ValidationException) when calling the CreateTrainingJob operation: Invalid MaxWaitTimeInSeconds. It must be present and be greater than or equal to MaxRuntimeInSeconds
4

2 回答 2

0

官方 AWS Managed Spot 培训链接在这里

它清楚地解决了以下问题:

设置EnableManagedSpotTrainingTrue指定MaxWaitTimeInSeconds. MaxWaitTimeInSeconds必须大于MaxRuntimeInSeconds

于 2021-09-05T00:18:23.803 回答
0

另一个 AWS SageMaker 文档不正确。仅在 Estimator 构造函数中将 train_use_spot_instances 设置为 true是不够的。

托管 Spot 培训:节省高达 90% 的 Amazon SageMaker 培训作业

设置它非常简单,就像在使用完全托管的服务时一样:

  • 如果您使用的是控制台,只需打开该功能即可。
  • 如果您使用的是 Amazon SageMaker 开发工具包,只需在 Estimator 构造函数中将 train_use_spot_instances 设置为 true

MaxWaitTimeInSeconds要求等于或大于MaxRuntimeInSeconds

SageMaker API 停止条件

MaxRuntimeInSeconds

训练或编译作业可以运行的最长时间(以秒为单位)。

MaxWaitTimeInSeconds

托管 Spot 训练作业必须完成的最长时间(以秒为单位)。它是等待 Spot 容量所花费的时间加上作业可以运行的时间。它必须等于或大于 MaxRuntimeInSeconds。如果在此期间作业未完成,Amazon SageMaker 将结束作业。

使固定

from sagemaker.tensorflow import TensorFlow


estimator = TensorFlow(
    entry_point="fashion_mnist_training.py",
    source_dir="src",
    metric_definitions=metric_definitions,
    hyperparameters=hyperparameters,
    role=role,
    input_mode='File',
    framework_version="2.3.1",
    py_version="py37",
    instance_count=1,
    instance_type="ml.m5.xlarge",
    use_spot_instances=True,
    max_wait= 23 * 60 * 60, 
    max_run = 24 * 60 * 60,     <----------
    base_job_name=base_job_name,
    checkpoint_s3_uri=checkpoint_s3_uri,
    model_dir=False 
)

有关的

SageMaker 使用对象检测算法管理 Spot 训练

于 2021-09-03T09:21:17.280 回答