gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 17:32:25 26 4
gpt4 key购买 nike

我正在尝试使用新的 Managed Spot Training 功能从现有模型开始训练对象检测模型,创建 Estimator 时使用的参数如下:

od_model = sagemaker.estimator.Estimator(get_image_uri(sagemaker.Session().boto_region_name, 'object-detection', repo_version="latest"),
Config['role'],
train_instance_count = 1,
train_instance_type = 'ml.p3.16xlarge',
train_volume_size = 50,
train_max_run = (48 * 60 * 60),
train_use_spot_instances = True,
train_max_wait = (72 * 60 * 60),
input_mode = 'File',
checkpoint_s3_uri = Config['train_checkpoint_uri'],
output_path = Config['s3_output_location'],
sagemaker_session = sagemaker.Session()
)

(上面对 Config 的引用是我用来提取/集中一些参数的配置数据结构)

当我运行上述程序时,出现以下异常:

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the CreateTrainingJob operation: MaxWaitTimeInSeconds above 3600 is not supported for the given algorithm.



如果我改变 train_max_wait到 3600 我得到这个异常:

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



然而变化 max_run_time到 3600 或更少对我来说不起作用,因为我预计这个模型需要几天的时间来训练(大数据集),实际上一个 epoch 需要一个多小时。

AWS blog post on Managed Spot TrainingMaxWaitTimeInSeconds仅限于 60 分钟:

For built-in algorithms and AWS Marketplace algorithms that don’t use checkpointing, we’re enforcing a maximum training time of 60 minutes (MaxWaitTimeInSeconds parameter).



早些时候,同一篇博文说:

Built-in algorithms: computer vision algorithms support checkpointing (Object Detection, Semantic Segmentation, and very soon Image Classification).



所以我不认为这是我的算法不支持检查点。事实上,该博客文章使用了对象检测和 48 小时的最大运行时间。所以我不认为这是算法限制。

正如您在上面看到的,我已经为检查点设置了一个 S3 URL。 S3 存储桶确实存在,并且训练容器可以访问它(它与放置训练数据和模型输出的存储桶相同,在打开现场训练之前,我对访问这些存储桶没有任何问题。

我的 boto 和 sagemaker 库是当前版本:
boto3 (1.9.239)
botocore (1.12.239)
sagemaker (1.42.3)

从阅读各种文档中我可以看出,我已经正确设置了所有内容。我的用例几乎与上面链接的博客文章中描述的完全相同,但我使用的是 SageMaker Python SDK 而不是控制台。

我真的很想尝试 Managed Spot Training 以节省一些钱,因为我要进行很长时间的培训。但是将超时限制为一小时对我的用例不起作用。有什么建议?

更新:如果我注释掉 train_use_spot_instancestrain_max_wait在常规按需实例上进行培训的选项 我的培训工作已成功创建。如果我然后尝试使用控制台来克隆作业并在克隆上打开 Spot 实例,我会得到相同的 ValidationException。

最佳答案

我今天再次运行我的脚本,它运行良好,没有 botocore.exceptions.ClientError异常(exception)。鉴于此问题同时影响了 Sagemeker 的 Puthon SDK 和控制台,我怀疑这可能是后端 API 的问题,而不是我的客户端代码的问题。

无论哪种方式,它现在都在工作。

关于python - SageMaker 使用对象检测算法管理 Spot 训练,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58177548/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com