自动停止和自动关停#
autostop(或autodown)功能会在集群空闲后自动停止(或销毁)集群。
使用 autostop,用户可以简单地提交作业并离开笔记本,同时确保不会产生不必要的开销:作业完成后,使用的集群会自动停止(以后可以重启)。
使用 autodown,使用的集群则会自动销毁(即终止)。
要为集群安排自动停止,请使用 sky autostop
或 sky launch -i <idle minutes>
# Launch a cluster with logging detached (the -d flag)
sky launch -d -c mycluster cluster.yaml
# Autostop the cluster after 10 minutes of idleness
sky autostop mycluster -i 10
# Use the default, 5 minutes of idleness
# sky autostop mycluster
# (Equivalent to the above) Use the -i flag:
sky launch -d -c mycluster cluster.yaml -i 10
要为集群安排自动关停,请将 --down
标志传递给 sky autostop
或 sky launch
# Add the --down flag to schedule autodown instead of autostop.
# This means the cluster will be torn down after 10 minutes of idleness.
sky launch -d -c mycluster2 cluster.yaml -i 10 --down
# Or:
sky autostop mycluster2 -i 10 --down
注意
自动停止/自动关停逻辑将由远程集群自动执行。您的本地机器无需保持开启即可使其生效。
要取消集群上任何已安排的自动停止/自动关停
sky autostop mycluster --cancel
要查看集群状态,请使用 sky status [--refresh]
$ sky status
NAME LAUNCHED RESOURCES STATUS AUTOSTOP COMMAND
mycluster 1 min ago 2x AWS(m4.2xlarge) UP 10 min sky launch -d -c ...
mycluster2 1 min ago 2x AWS(m4.2xlarge) UP 10 min(down) sky launch -d -c ...
# Refresh the statuses by querying the cloud providers
$ sky status --refresh
I 06-27 13:36:11 backend_utils.py:2273] Autodowned cluster: mycluster2
NAME LAUNCHED RESOURCES STATUS AUTOSTOP COMMAND
mycluster 11 min ago 2x AWS(m4.2xlarge) STOPPED 10 min sky launch -d -c ...
请注意,sky status
显示的是缓存状态,对于已安排自动停止/自动关停的集群可能已过时。要查询这些集群的最新状态,请使用 sky status --refresh
。