

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

# Slurm 的多实例类型分配
<a name="slurm-multiple-instance-allocation-v3"></a>

从 3.3.0 AWS ParallelCluster 版开始，您可以将集群配置为从计算资源的一组已定义的实例类型中进行分配。可以基于 Amazon EC2 机队的低成本或最佳容量策略进行分配。

这组已定义的实例类型必须全部具有相同数量的 v，CPUs 或者如果禁用了多线程，则必须具有相同数量的内核。此外，这组实例类型必须具有相同制造商的相同数量的加速器。如果 [`Efa`](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Efa)/[`Enabled`](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Efa-Enabled) 设置为 `true`，则实例必须支持 EFA。有关更多信息和要求，请参阅 [`Scheduling`](Scheduling-v3.md)/[`SlurmQueues`](Scheduling-v3.md#Scheduling-v3-SlurmQueues)/[`AllocationStrategy`](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-AllocationStrategy) 和 [`ComputeResources`](Scheduling-v3.md#Scheduling-v3-SlurmQueues-ComputeResources)/[`Instances`](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Instances)。

`capacity-optimized`根据您的[CapacityType](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-CapacityType)配置 [`AllocationStrategy`](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-AllocationStrategy)，可以设置为`lowest-price`或。

在 [`Instances`](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Instances) 中，您可以配置一组实例类型。

**注意**  
[从 3.7.0 AWS ParallelCluster 版开始，如果您在实例中配置了多个实例类型，则`EnableMemoryBasedScheduling`可以启用。](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Instances)  
适用于 3.2.0 到 3.6 AWS ParallelCluster 版本。 {{x}}[，如果您在实例中配置了多个实例类型，则`EnableMemoryBasedScheduling`无法启用。](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Instances)

以下示例显示了如何查询 v CPUs、EFA 支持和架构的实例类型。

Query InstanceTypes 采用 96 v CPUs 和 x86\_64 架构。

```
$ aws ec2 describe-instance-types --region {{region-id}} \
  --filters "Name=vcpu-info.default-vcpus,Values=96" "Name=processor-info.supported-architecture,Values=x86_64" \
  --query "sort_by(InstanceTypes[*].{InstanceType:InstanceType,MemoryMiB:MemoryInfo.SizeInMiB,CurrentGeneration:CurrentGeneration,VCpus:VCpuInfo.DefaultVCpus,Cores:VCpuInfo.DefaultCores,Architecture:ProcessorInfo.SupportedArchitectures[0],MaxNetworkCards:NetworkInfo.MaximumNetworkCards,EfaSupported:NetworkInfo.EfaSupported,GpuCount:GpuInfo.Gpus[0].Count,GpuManufacturer:GpuInfo.Gpus[0].Manufacturer}, &InstanceType)" \
  --output table
```

Query InstanceTypes 拥有 64 个内核、支持 EFA 和 arm64 架构。

```
$ aws ec2 describe-instance-types --region {{region-id}} \
  --filters "Name=vcpu-info.default-cores,Values=64" "Name=processor-info.supported-architecture,Values=arm64" "Name=network-info.efa-supported,Values=true" --query "sort_by(InstanceTypes[*].{InstanceType:InstanceType,MemoryMiB:MemoryInfo.SizeInMiB,CurrentGeneration:CurrentGeneration,VCpus:VCpuInfo.DefaultVCpus,Cores:VCpuInfo.DefaultCores,Architecture:ProcessorInfo.SupportedArchitectures[0],MaxNetworkCards:NetworkInfo.MaximumNetworkCards,EfaSupported:NetworkInfo.EfaSupported,GpuCount:GpuInfo.Gpus[0].Count,GpuManufacturer:GpuInfo.Gpus[0].Manufacturer}, &InstanceType)" \
  --output table
```

下一个集群配置示例片段显示了如何使用这些配置 InstanceType 以及 AllocationStrategy 属性。

```
...
 Scheduling:
  Scheduler: slurm
  SlurmQueues:
    - Name: queue-1
      CapacityType: ONDEMAND
      AllocationStrategy: lowest-price
      ...
      ComputeResources:
        - Name: computeresource1
          Instances:
            - InstanceType: r6g.2xlarge
            - InstanceType: m6g.2xlarge
            - InstanceType: c6g.2xlarge
          MinCount: 0
          MaxCount: 500
        - Name: computeresource2
          Instances:
            - InstanceType: m6g.12xlarge
            - InstanceType: x2gd.12xlarge
          MinCount: 0
          MaxCount: 500
...
```