生命周期配置文件无法自动终止 amazon sagemaker studio 实例

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

我正在尝试配置生命周期配置(LCC)文件,以便在达到 sagemaker 代码编辑器的空闲阈值时实现自动终止功能。我已经遵循了这个问题中的解决方案。成功完成这些步骤后,我可以在 amazon sagemaker studio UI 中查看并选择 LCC 文件,但实例在 1 小时空闲时间后不会关闭。

这是 LCC 文件:https://github.com/aws-samples/sagemaker-studio-apps-lifecycle-config-examples/blob/main/code-editor/auto-stop-idle/on-start。嘘

amazon-web-services visual-studio-code amazon-sagemaker
1个回答
0
投票

如果您打算使用 CodeEditor,您的一般方法是正确的。

在上一个问题中,您指的是 JupyterLab。我建议验证您实际上使用的是 CodeEditor 而不是 JupyterLab。 SageMaker Studio 提供这两种编辑器,并且每个编辑器都需要注册不同的 LCC。

对于 JupyterLab,您可以在此处找到 LCC 脚本以及有关如何注册脚本的说明:https://github.com/aws-samples/sagemaker-studio-apps-lifecycle-config-examples/tree/main/jupyterlab /自动停止怠速

如果您打算使用 CodeEditor 并且 LCC 无法正常工作,我建议您检查您的 CloudWatch 日志。 LCC 脚本建立一个 cron 作业,每两分钟检查一次空闲状态并将其记录到 CloudWatch。

您还可以选择在 CodeEditor 应用程序中手动调用脚本。在代码编辑器中打开终端(终端 > 新终端)并执行:

# this example uses 1800 seconds as idle time threshold
/opt/conda/bin/python /var/tmp/auto-stop-idle/sagemaker_code_editor_auto_shut_down/auto_stop_idle.py --time 1800 --region $AWS_DEFAULT_REGION

这应该提供如下输出:

2024-04-16T06:16:55.359295z - [auto-stop-idle] - Logging time difference between current time and time files were last changed 80.18277621269226.
2024-04-16T06:16:55.359445z - [auto-stop-idle] - Logging time difference between current time and time files were last changed inf.
2024-04-16T06:16:55.359476z - [auto-stop-idle] - SageMaker Code Editor app is not idle. Passing check.

如果超过空闲时间,运行脚本实际上会终止您的 CodeEditor 应用程序。这应该是测试脚本是否在您的环境中运行的快速方法。

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