【问题标题】:SageMaker Estimator use_spot_instances causes Invalid MaxWaitTimeInSecondsSageMaker Estimator use_spot_instances 导致 Invalid MaxWaitTimeInSeconds
【发布时间】:2021-09-03 09:21:17
【问题描述】:

Managed Spot Training: Save Up to 90% On Your Amazon SageMaker Training Jobs 说:

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

  • 如果您使用控制台,只需打开该功能即可。
  • 如果您使用的是 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

【问题讨论】:

    标签: amazon-web-services amazon-sagemaker spot-instances


    【解决方案1】:

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

    Managed Spot Training: Save Up to 90% On Your Amazon SageMaker Training Jobs:

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

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

    MaxWaitTimeInSeconds 必须等于或大于MaxRuntimeInSeconds

    SageMaker API StoppingCondition

    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 Managed Spot Training with Object Detection algorithm

    【讨论】:

      【解决方案2】:

      The official AWS Managed Spot Training Link is here

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

      EnableManagedSpotTraining 设置为True 并指定MaxWaitTimeInSecondsMaxWaitTimeInSeconds 必须大于 MaxRuntimeInSeconds

      【讨论】:

        猜你喜欢
        • 2020-08-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-24
        • 2017-04-15
        • 2020-07-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多