如何自动停止 Sagemaker 笔记本

问题描述 投票:0回答:1

我需要一个可以在笔记本实例空闲或未使用时停止它的解决方案

我正在尝试使用生命周期配置,但是当我将其添加到我的实例时,我无法启动它

我添加了这段代码 #!/bin/bash 设置-e

空闲时间=300

echo“正在获取自动停止脚本” wget -O autostop.py https://raw.githubusercontent.com/mariokostelac/sagemaker-setup/master/scripts/auto-stop-idle/autostop.py

echo“在 cron 中启动 SageMaker 自动停止脚本” (crontab -l 2>/dev/null; echo "*/5 * * * * /bin/bash -c '/usr/bin/python3 $DIR/autostop.py --time ${IDLE_TIME} | tee -a /home/ec2-user/SageMaker/auto-stop-idle.log'") | crontab -

echo“更改cloudwatch配置” 卷曲https://raw.githubusercontent.com/mariokostelac/sagemaker-setup/master/scripts/publish-logs-to-cloudwatch/on-start.sh | sudo bash -s auto-stop-idle /home/ec2-user/SageMaker/auto-stop-idle.log 但还是无法启动实例

amazon-sagemaker
1个回答
0
投票

请注意,下面描述的方法仅特定于 SageMaker Notebook 实例。如果您使用 SageMaker Studio 笔记本,则需要不同的生命周期配置

对于 SageMaker Notebook 实例,此 GitHub 存储库 提供了生命周期配置的各种示例,包括 auto-stop-idle 脚本。如果您的实例空闲超过一小时,此脚本将自动关闭您的实例。

要实现这一点,您需要:

  1. 创建包含自动停止空闲脚本的生命周期配置
  2. 在创建或编辑笔记本实例时将此配置附加到您的实例

如果您应该在 Notebook 实例中使用自定义 VPC,请注意此特定脚本需要互联网访问。

© www.soinside.com 2019 - 2024. All rights reserved.