计算资源调配#
SkyPilot 内置了自动故障转移预配器,当无法预配请求的资源时,它会自动重试在不同区域(或云)中预配集群。发生此类故障的原因有很多种:
容量不足(在某个区域或云中)
配额不足(在某个区域或云中)
自动故障转移对于预配稀缺资源(例如,GPU/TPU、大量 CPU、Spot 实例)特别有用。用户无需手动搜索可以提供请求资源的区域(或云)。
提示
使用此功能无需任何操作。每当需要预配新集群时,例如在 sky launch
期间,自动故障转移都会自动启用。
如果任务请求了特定的 cloud
、region
或 zone
,自动故障转移只会在指定的地点内重试。
预配 GPU#
要预配 GPU 或其他加速器,如果您使用 任务 YAML,请使用 resources.accelerators
字段
resources:
accelerators: A100
# accelerators: A100:1
# accelerators: A100:8
# accelerators: A100-80GB:8
同样,您可以在 sky launch
中使用 CLI 参数 --gpus
来指定加速器
sky launch --gpus A100
sky launch --gpus A100:1
sky launch --gpus A100:8
sky launch --gpus A100-80GB:8
使用 sky show-gpus
查看所有支持的加速器名称。
跨区域故障转移#
预配器首先会在任务选择的云中的所有区域内重试。
AI 中常用的一种高端 GPU 是 NVIDIA A100 GPU。这些 GPU 通常需求量很大,难以获取。让我们看看 SkyPilot 的自动故障转移预配器如何处理此类请求
$ sky launch -c gpu --gpus A100
...
Launching a new cluster 'gpu'. Proceed? [Y/n]:
⚙️ Launching on GCP us-central1 (us-central1-a).
W 10-11 18:25:57 instance_utils.py:112] Got return codes 'VM_MIN_COUNT_NOT_REACHED', 'ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS' in us-central1-a: 'Requested minimum count of 1 VMs could not be created'; "The zone 'projects/xxxxxx/zones/us-central1-a' does not have enough resources available to fulfill the request. '(resource type:compute)'"
...
⚙️ Launching on GCP us-central1 (us-central1-f)
...
⚙️ Launching on GCP us-west1 (us-west1-a)
...
✓ Cluster launched: a100-8. View logs at: ~/sky_logs/sky-2024-10-11-18-32-48-894132/provision.log
GCP 被选为运行任务的最佳云。美国中部任何区域都没有容量,因此自动故障转移预配器转而切换到美国西部,从而成功预配了我们的实例。
跨云故障转移#
如果所选云中的所有区域都失败了,预配器将尝试在下一个最便宜的云上重试。
这是一个请求 8 个 A100 GPU 时进行跨云故障转移的示例。Azure 中的所有区域都未能提供资源,因此预配器切换到 GCP,并在一个区域成功获取资源
$ sky launch -c a100-8 --gpus A100:8
Considered resources (1 node):
----------------------------------------------------------------------------------------------------
CLOUD INSTANCE vCPUs Mem(GB) ACCELERATORS REGION/ZONE COST ($) CHOSEN
----------------------------------------------------------------------------------------------------
Azure Standard_ND96asr_v4 96 900 A100:8 eastus 27.20 ✔
GCP a2-highgpu-8g 96 680 A100:8 us-central1-a 29.39
AWS p4d.24xlarge 96 1152 A100:8 us-east-1 32.77
----------------------------------------------------------------------------------------------------
Launching a new cluster 'a100-8'. Proceed? [Y/n]:
...
⚙️ Launching on Azure eastus.
E 10-11 18:24:59 instance.py:457] Failed to create instances: [azure.core.exceptions.HttpResponseError] (InvalidTemplateDeployment)
sky.exceptions.ResourcesUnavailableError: Failed to acquire resources in all zones in eastus
...
⚙️ Launching on GCP us-central1 (us-central1-a).
W 10-11 18:25:57 instance_utils.py:112] Got return codes 'VM_MIN_COUNT_NOT_REACHED', 'ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS' in us-central1-a: 'Requested minimum count of 1 VMs could not be created'; "The zone 'projects/xxxxxx/zones/us-central1-a' does not have enough resources available to fulfill the request. '(resource type:compute)'"
...
⚙️ Launching on GCP us-central1 (us-central1-b).
Instance is up.
✓ Cluster launched: a100-8. View logs at: ~/sky_logs/sky-2024-10-11-18-24-14-357884/provision.log
多个候选 GPU#
如果一个任务可以在不同的 GPU 上运行,用户可以指定多个候选 GPU,SkyPilot 将自动找到最便宜的可用 GPU。
要允许 SkyPilot 选择任何候选 GPU,请在任务 yaml 中指定一组候选 GPU
resources:
accelerators: {A10:1, L4:1, A10g:1}
在上面的示例中,SkyPilot 将尝试使用 sky launch task.yaml
在 A10、L4 和 A10g GPU 集合中预配任意最便宜的可用 GPU。
$ sky launch task.yaml
...
-----------------------------------------------------------------------------------------------------
CLOUD INSTANCE vCPUs Mem(GB) ACCELERATORS REGION/ZONE COST ($) CHOSEN
-----------------------------------------------------------------------------------------------------
Azure Standard_NV6ads_A10_v5 6 55 A10:1 eastus 0.45 ✔
GCP g2-standard-4 4 16 L4:1 us-east4-a 0.70
AWS g5.xlarge 4 16 A10G:1 us-east-1 1.01
-----------------------------------------------------------------------------------------------------
要指定偏好顺序,请在任务 yaml 中使用候选 GPU 列表
resources:
accelerators: [A10:1, A10g:1, L4:1]
在上面的示例中,SkyPilot 将首先尝试预配一个 A10 GPU,然后是一个 A10g GPU,最后是一个 L4 GPU。
多个候选资源#
如果任务希望指定多个候选资源(不仅仅是 GPU),用户可以使用偏好注解指定候选资源列表
resources:
ordered: # Candidate resources in a preference order
- cloud: gcp
accelerators: A100-80GB
- instance_type: g5.xlarge
- cloud: azure
region: eastus
accelerators: A100
resources:
any_of: # Candidate resources that can be chosen in any order
- cloud: gcp
accelerators: A100-80GB
- instance_type: g5.xlarge
- cloud: azure
region: eastus
accelerators: A100
提示
列表项以前缀 -
开头,每个项都是一个字典,包含候选资源的字段。ordered
和 any_of
指示了对候选资源的偏好。
示例:只允许在特定区域/云中使用以下任意 GPU 启动:A10g:8、A10:8、L4:8 和 A100:8
resources:
accelerators: {A10g:8, A10:8, L4:8, A100:8}
any_of:
# AWS:
- region: us-east-1
- region: us-east-2
- region: us-west-1
- region: us-west-2
# GCP
- region: us-central1
- region: us-east1
- region: us-east4
- region: us-west1
- region: us-west2
- region: us-west3
- region: us-west4
提示
指定的没有该加速器的区域将自动被忽略。
这将生成以下输出
$ sky launch -c mycluster task.yaml
...
Considered resources (1 node):
---------------------------------------------------------------------------------------------
CLOUD INSTANCE vCPUs Mem(GB) ACCELERATORS REGION/ZONE COST ($) CHOSEN
---------------------------------------------------------------------------------------------
GCP g2-standard-96 96 384 L4:8 us-east4-a 7.98 ✔
AWS g5.48xlarge 192 768 A10G:8 us-east-1 16.29
GCP a2-highgpu-8g 96 680 A100:8 us-east1-b 29.39
AWS p4d.24xlarge 96 1152 A100:8 us-east-1 32.77
---------------------------------------------------------------------------------------------
Launching a new cluster 'mycluster'. Proceed? [Y/n]: