

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# `[compute_resource]` 部分
<a name="compute-resource-section"></a>

定义计算资源的配置设置。[`[compute_resource]` 部分](#compute-resource-section)由 [`[queue]` 部分](queue-section.md)中的 [`compute_resource_settings`](queue-section.md#queue-compute-resource-settings) 设置引用。只有当 [`scheduler`](cluster-definition.md#scheduler) 设置为 `slurm` 时，才支持 [`[compute_resource]` 部分](#compute-resource-section)。

格式为`[compute_resource <compute-resource-name>]`。 *compute-resource-name*必须以字母开头，不能超过 30 个字符，并且只能包含字母、数字、连字符 (-) 和下划线 (\$1)。

```
[compute_resource cr1]
instance_type = c5.xlarge
min_count = 0
initial_count = 2
max_count = 10
spot_price = 0.5
```

**注意**  
2.9.0 AWS ParallelCluster 版本中增加了对该[`[compute_resource]`部分](#compute-resource-section)的支持。

**Topics**
+ [`initial_count`](#compute-resource-initial-count)
+ [`instance_type`](#compute-resource-instance-type)
+ [`max_count`](#compute-resource-max-count)
+ [`min_count`](#compute-resource-min-count)
+ [`spot_price`](#compute-resource-spot-price)

## `initial_count`
<a name="compute-resource-initial-count"></a>

**（可选）**设置要为此计算资源启动的 Amazon EC2 实例的初始数量。至少在计算资源中启动了这么多节点之后，集群创建才会完成。如果队列的 [`compute_type`](queue-section.md#queue-compute-type) 设置为 `spot`，并且没有足够的竞价型实例可用，则集群创建可能会超时并失败。任何大于 [`min_count`](#compute-resource-min-count) 设置的计数均为受 [`scaledown_idletime`](scaling-section.md#scaledown-idletime) 设置控制的动态容量。该设置替代 [`initial_queue_size`](cluster-definition.md#configuration-initial-queue-size) 设置。

默认值为 `0`。

```
initial_count = 2
```

[更新策略：必须停止计算实例集才能更改此设置以进行更新。](using-pcluster-update.md#update-policy-compute-fleet)

## `instance_type`
<a name="compute-resource-instance-type"></a>

**（必需）**定义用于此计算资源的 Amazon EC2 实例类型。该实例类型的架构必须与用于 [`master_instance_type`](cluster-definition.md#master-instance-type) 设置的架构相同。对于 [`[queue]` 部分](queue-section.md)引用的每个 [`[compute_resource]` 部分](#compute-resource-section)，`instance_type` 设置必须是唯一的。该设置替代 [`compute_instance_type`](cluster-definition.md#compute-instance-type) 设置。

```
instance_type = t2.micro
```

[更新策略：必须停止计算实例集才能更改此设置以进行更新。](using-pcluster-update.md#update-policy-compute-fleet)

## `max_count`
<a name="compute-resource-max-count"></a>

**（可选）**设置可在该计算资源中启动的 Amazon EC2 实例的最大数量。任何大于 [`initial_count`](#compute-resource-initial-count) 设置的计数都将在关闭模式下启动。该设置替代 [`max_queue_size`](cluster-definition.md#configuration-max-queue-size) 设置。

默认值为 `10`。

```
max_count = 10
```

[更新策略：要将队列大小减至当前节点数以下，需要先停止计算实例集。](using-pcluster-update.md#update-policy-max-count)

**注意**  
在 AWS ParallelCluster 版本 2.0.0 到 2.9.1 的计算队列停止之前，更新策略不支持更改`max_count`设置。

## `min_count`
<a name="compute-resource-min-count"></a>

**（可选）**设置可以在此计算资源中启动的 Amazon EC2 实例的最小数量。这些节点均为静态容量。至少在计算资源中启动了此数量的节点之后，集群创建才会完成。

默认值为 `0`。

```
min_count = 1
```

[更新策略：减少队列中静态节点的数量需要先停止计算实例集。](using-pcluster-update.md#update-policy-min-count)

**注意**  
在 AWS ParallelCluster 版本 2.0.0 到 2.9.1 的计算队列停止之前，更新策略不支持更改`min_count`设置。

## `spot_price`
<a name="compute-resource-spot-price"></a>

**（可选）**设置此计算资源的最高竞价价格。仅当包含此计算资源的队列的 [`compute_type`](queue-section.md#queue-compute-type) 设置设为 `spot` 时才使用。该设置替代 [`spot_price`](cluster-definition.md#spot-price) 设置。

如果您不指定值，则按竞价价格进行收费，最高为按需价格。

有关查找满足您需求的竞价型实例的帮助，请参阅[竞价型实例顾问](https://aws.amazon.com/ec2/spot/instance-advisor/)。

```
spot_price = 1.50
```

[更新策略：必须停止计算实例集才能更改此设置以进行更新。](using-pcluster-update.md#update-policy-compute-fleet)