

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 搜尋訓練計畫供應項目
<a name="search-training-plan-offerings-api-cli-sdk"></a>

若要建立訓練計畫，請先呼叫 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_SearchTrainingPlanOfferings.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_SearchTrainingPlanOfferings.html) API 操作，將您的計劃要求 (例如執行個體類型、計數和所需時段) 做為輸入參數傳遞。訓練計畫專屬於其目標資源。確定您指定計畫將用於哪些目標資源 (`training-job` 或 `hyperpod-cluster`)。API 會傳回符合您要求的可用方案清單。如果找不到合適的方案，您可能需要調整要求並再次搜尋。

此 API 呼叫會擷取最符合您容量需求的訓練計畫方案。回應中傳回的每個 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_TrainingPlanOffering.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_TrainingPlanOffering.html) 都會以唯一的方案 ID 識別。清單中的第一個方案代表其最符合您的要求。如果在您指定的日期內沒有可用的訓練計畫，則清單為空白。調整您的搜尋條件並尋找一組新的方案。
+ 保留持續時間從 1 天到 182 天，增量單位為 1 天。
+ 保留執行個體數量選項為 1、2、4、8、16、32 或 64 個執行個體。

若要了解 SageMaker 訓練計畫支援的可用執行個體清單，請參閱 [支援的執行個體類型 AWS 區域和定價](reserve-capacity-with-training-plans.md#training-plans-supported-instances-and-regions)。

下列範例使用 AWS CLI 命令來請求具有指定執行個體類型、計數和時間資訊的培訓計劃方案。

```
# List training plan offerings with instance type, instance count, duration in hours, start time after, and end time before.
aws sagemaker search-training-plan-offerings \
--target-resources "training-job" \
--instance-type "ml.p4d.24xlarge" \
--instance-count 1 \
--duration-hours 15 \
--start-time-after "1737484800"
--end-time-before "1737657600"
```

此 JSON 文件是來自 SageMaker 訓練計畫 API 的範例回應。回應提供符合所指定容量要求的多個可用訓練計畫方案的相關資訊。它包含三種不同的方案，其中具有不同的持續時間、預付費用和開始/結束時間，全部都使用相同的執行個體類型並將訓練任務設為目標。

```
{
    "TrainingPlanOfferings": [
        {
            "TrainingPlanOfferingId": "tpo-SHA-256-hash-value",
            "TargetResources": [
                "training-job"
            ],
            "RequestedStartTimeAfter": "2025-01-21T11:08:27.704000-08:00",
            "DurationHours": 15,
            "DurationMinutes": 51,
            "UpfrontFee": "xxxx.xx",
            "CurrencyCode": "USD",
            "ReservedCapacityOfferings": [
                {
                    "InstanceType": "ml.p4d.24xlarge",
                    "InstanceCount": 1,
                    "AvailabilityZone": "us-west-2a",
                    "DurationHours": 15,
                    "DurationMinutes": 51,
                    "StartTime": "2025-01-21T11:39:00-08:00",
                    "EndTime": "2025-01-22T03:30:00-08:00"
                }
            ]
        },
        {
            "TrainingPlanOfferingId": "tpo-SHA-256-hash-value",
            "TargetResources": [
                "training-job"
            ],
            "RequestedStartTimeAfter": "2025-01-21T11:08:27.704000-08:00",
            "DurationHours": 39,
            "DurationMinutes": 51,
            "UpfrontFee": "xxxx.xx",
            "CurrencyCode": "USD",
            "ReservedCapacityOfferings": [
                {
                    "InstanceType": "ml.p4d.24xlarge",
                    "InstanceCount": 1,
                    "AvailabilityZone": "us-west-2a",
                    "DurationHours": 39,
                    "DurationMinutes": 51,
                    "StartTime": "2025-01-21T11:39:00-08:00",
                    "EndTime": "2025-01-23T03:30:00-08:00"
                }
            ]
        },
        {
            "TrainingPlanOfferingId": "tpo-SHA-256-hash-value",
            "TargetResources": [
                "training-job"
            ],
            "RequestedStartTimeAfter": "2025-01-21T11:08:27.704000-08:00",
            "DurationHours": 24,
            "DurationMinutes": 0,
            "UpfrontFee": "xxxx.xx",
            "CurrencyCode": "USD",
            "ReservedCapacityOfferings": [
                {
                    "InstanceType": "ml.p4d.24xlarge",
                    "InstanceCount": 1,
                    "AvailabilityZone": "us-west-2a",
                    "DurationHours": 24,
                    "DurationMinutes": 0,
                    "StartTime": "2025-01-22T03:30:00-08:00",
                    "EndTime": "2025-01-23T03:30:00-08:00"
                }
            ]
        }
    ]
}
```

以下是如何使用 AWS CLI 搜尋包含 UltraServers 之訓練計劃方案的範例命令。

```
aws sagemaker search-training-plan-offerings \
--ultra-server-type ml.c6i-32xlargesc \
--ultra-server-count 1 \
--duration-hours 24 \
--target-resources hyperpod-cluster
--start-time-after "1737484800" \
--end-time-before "1737657600"
```

```
{
    "TrainingPlanOfferings": [
        {
            "TrainingPlanOfferingId": "tpo-SHA-256-hash-value",
            "TargetResources": [
                "training-job"
            ],
            "RequestedStartTimeAfter": "2025-07-21T16:59:25.760000+00:00",
            "DurationHours": 24,
            "DurationMinutes": 0,
            "UpfrontFee": "0.24",
            "CurrencyCode": "USD",
            "ReservedCapacityOfferings": [
                {
                    "ReservedCapacityType": "UltraServer",
                    "UltraServerType": "ml.u-p6e-gb200x72",
                    "UltraServerCount": 1,
                    "InstanceType": "ml.p6e-gb200.36xlarge",
                    "InstanceCount": 18,
                    "AvailabilityZone": "us-east-2a",
                    "DurationHours": 24,
                    "DurationMinutes": 0,
                    "StartTime": "2025-07-22T11:30:00+00:00",
                    "EndTime": "2025-07-23T11:30:00+00:00"
                }
            ]
        }
    ]
}
```

下列各節會針對 `SearchTrainingPlanOfferings` API 操作定義必要和選用的輸入請求參數。

## 必要參數
<a name="search-training-plan-options-required-params"></a>

呼叫 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_SearchTrainingPlanOfferings.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_SearchTrainingPlanOfferings.html) API 列出符合您要求的訓練計畫方案時，您必須提供下列值：
+ `TargetResources`：將使用計畫的目標資源 (`training-job` 或 `hyperpod-cluster`)。預設值為 `training-job`。訓練計畫專屬於其目標資源。
  + 專為 SageMaker 訓練任務設計的訓練計畫只能用來排程和執行訓練任務。
  + HyperPod 叢集的訓練計畫專門用來將運算資源提供給叢集的執行個體群組。
+ `InstanceType`：要佈建的執行個體類型。`InstanceType` 必須屬於支援的類型。

  若要了解 SageMaker 訓練計畫支援的可用執行個體清單，請參閱 [支援的執行個體類型 AWS 區域和定價](reserve-capacity-with-training-plans.md#training-plans-supported-instances-and-regions)。
+ `InstanceCount`：要佈建的執行個體數量。如果執行個體數量大於 1，則應該是 2 的次方。
+ `DurationHour`：所請求計畫的總持續時間，以小時為單位。`DurationHour` 會四捨五入至最接近的 24 倍數。

## 選用的參數
<a name="search-training-plan-options-optional-params"></a>

下列各節提供一些選用參數的詳細資訊，您可以將這些參數傳給 `SearchTrainingPlanOfferings` API 請求。
+ `StartTimeAfter`：指定計畫的請求開始時間。`StartTimeAfter` 未來應該是 `timestamp` 或 `ISO 8601 date/time` 值。
+ `EndTimeBefore`：以 `timestamp` 或 `ISO 8601 date/time` 格式指定計畫的請求結束時間。`EndTimeBefore` 應距開始時間至少 24 小時。
+ `UltraServerType`：指定要搜尋的 UltraServer 類型。如需 UltraServer 的詳細資訊，請參閱 [SageMaker AI 中的 UltraServer](reserve-capacity-with-training-plans.md#training-plans-ultraservers)。
+ `UltraServerCount`：指定要搜尋的 UltraServer 數量。