如何在 SageMaker 上安排任务
How to schedule tasks on SageMaker
我在 SageMaker 上有一个笔记本,我想每晚 运行。安排此任务的最佳方式是什么。有没有办法 运行 bash 脚本并从 SageMaker 安排 Cron 作业?
我认为没有任何方法可以在 sagemaker 上安排任务。
笔记本更多地用于与 SageMaker 运行时交互。哪个更适合训练和托管 ML 模型。
我假设你想每晚重新训练你的模型。有两种方法可以实现这一点,在其他地方重新训练您的模型,然后上传到 S3 并每晚使用外部脚本重新创建您的 docker 容器。
要么
提供您自己的 docker 容器,其中安排了一个 cron 作业。将其交给 SageMaker 进行部署。
您可以访问 AWS 控制台 Jupyter 页面中的笔记本终端(在右上角,select new --> Terminal)。如果 cron 对你来说足够了,也许里面的 crontab
就足够了。
如果您有大型、昂贵的作业可以 运行 在容器中,也可以考虑 AWS Batch。在那里你可以尝试对所需实例使用现货定价。批处理作业可以由 Cloudwatch Events 启动(例如 cron 触发器)。
Amazon SageMaker 是一组 API,可以帮助各种机器学习和数据科学任务。这些 API 可以从各种来源调用,例如 CLI,SDK or specifically from schedule AWS Lambda functions (see here for documentation: https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html )
Amazon SageMaker 的主要部分是笔记本实例、训练和调整作业以及 real-time 预测的模型托管。每个都有您可能想要的不同类型的时间表。最受欢迎的是:
- 停止和启动笔记本实例 - 由于笔记本实例用于交互式 ML 模型开发,因此您并不真正需要它们 运行在夜间或周末。您可以安排 Lambda 函数在早上调用 stop-notebook-instance API at the end of the working day (8PM, for example), and the start-notebook-instance API。请注意,您还可以在笔记本实例上 运行 crontab(从 Jupyter 界面打开本地终端后)。
- 刷新 ML 模型 - 根据一直流入系统的新数据自动执行模型 re-training 是 SageMaker 的一个常见问题更容易解决。调用 create-training-job API from a scheduled Lambda function (or even from a CloudWatch Event that is monitoring the performance of the existing models), pointing to the S3 bucket where the old and new data resides, can create a refreshed model that you can now deploy into an A/B testing environment .
----- 更新(感谢@snat2100 评论)-----
- 创建和删除 Real-time 端点 - 如果不需要 24/7 全天候使用实时端点(例如,为在工作日和工作时间工作的公司内部用户提供服务),你也可以在晚上 create the endpoints in the morning and delete them。
截至 2020 年年中,AWS 为 运行 笔记本提供了多种选项作为 cron 作业。它使用 Papermill 按 运行 注入参数,您还可以使用 CLI 按需 运行 笔记本。
你可以:
(1) 直接使用 AWS API 或 CLI; (2) 使用便利包,或 (3) 使用 Jupyter Lab 扩展。
有关示例,请参阅 this tutorial and the Quick Start guide。
现在通过 2 项服务简化了很多任务,一个是 Stepfunctions,它允许您通过多个 AWS 的连接器创建工作流 services.As 例如,一个简单的管道可以通过启动爬虫来启动然后是胶水作业,最后是 sagemaker notebook,现在要安排此过程,将 eventbrige 用作此任务的 cron,请注意 SF 是高度可参数化的。
我在 SageMaker 上有一个笔记本,我想每晚 运行。安排此任务的最佳方式是什么。有没有办法 运行 bash 脚本并从 SageMaker 安排 Cron 作业?
我认为没有任何方法可以在 sagemaker 上安排任务。 笔记本更多地用于与 SageMaker 运行时交互。哪个更适合训练和托管 ML 模型。
我假设你想每晚重新训练你的模型。有两种方法可以实现这一点,在其他地方重新训练您的模型,然后上传到 S3 并每晚使用外部脚本重新创建您的 docker 容器。 要么 提供您自己的 docker 容器,其中安排了一个 cron 作业。将其交给 SageMaker 进行部署。
您可以访问 AWS 控制台 Jupyter 页面中的笔记本终端(在右上角,select new --> Terminal)。如果 cron 对你来说足够了,也许里面的 crontab
就足够了。
如果您有大型、昂贵的作业可以 运行 在容器中,也可以考虑 AWS Batch。在那里你可以尝试对所需实例使用现货定价。批处理作业可以由 Cloudwatch Events 启动(例如 cron 触发器)。
Amazon SageMaker 是一组 API,可以帮助各种机器学习和数据科学任务。这些 API 可以从各种来源调用,例如 CLI,SDK or specifically from schedule AWS Lambda functions (see here for documentation: https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html )
Amazon SageMaker 的主要部分是笔记本实例、训练和调整作业以及 real-time 预测的模型托管。每个都有您可能想要的不同类型的时间表。最受欢迎的是:
- 停止和启动笔记本实例 - 由于笔记本实例用于交互式 ML 模型开发,因此您并不真正需要它们 运行在夜间或周末。您可以安排 Lambda 函数在早上调用 stop-notebook-instance API at the end of the working day (8PM, for example), and the start-notebook-instance API。请注意,您还可以在笔记本实例上 运行 crontab(从 Jupyter 界面打开本地终端后)。
- 刷新 ML 模型 - 根据一直流入系统的新数据自动执行模型 re-training 是 SageMaker 的一个常见问题更容易解决。调用 create-training-job API from a scheduled Lambda function (or even from a CloudWatch Event that is monitoring the performance of the existing models), pointing to the S3 bucket where the old and new data resides, can create a refreshed model that you can now deploy into an A/B testing environment .
----- 更新(感谢@snat2100 评论)-----
- 创建和删除 Real-time 端点 - 如果不需要 24/7 全天候使用实时端点(例如,为在工作日和工作时间工作的公司内部用户提供服务),你也可以在晚上 create the endpoints in the morning and delete them。
截至 2020 年年中,AWS 为 运行 笔记本提供了多种选项作为 cron 作业。它使用 Papermill 按 运行 注入参数,您还可以使用 CLI 按需 运行 笔记本。
你可以:
(1) 直接使用 AWS API 或 CLI; (2) 使用便利包,或 (3) 使用 Jupyter Lab 扩展。
有关示例,请参阅 this tutorial and the Quick Start guide。
现在通过 2 项服务简化了很多任务,一个是 Stepfunctions,它允许您通过多个 AWS 的连接器创建工作流 services.As 例如,一个简单的管道可以通过启动爬虫来启动然后是胶水作业,最后是 sagemaker notebook,现在要安排此过程,将 eventbrige 用作此任务的 cron,请注意 SF 是高度可参数化的。