为什么我无法创建附加了推理加速器的 ECS 任务定义?

Why can't I create an ECS Task Definition with Inference Accelerators attached?

我想尝试将推理加速器附加到 ECS 任务。 我创建了以下 Cloudformation 模板:

{
    "Resources": {
        "Task": {
          "Type" : "AWS::ECS::TaskDefinition",
          "Properties" : {
              "ContainerDefinitions" : [
                  {
                      "Name": "TestAccelerated",
                      "Image": "xxxxxxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/myimage",
                      "Essential": true,
                      "ResourceRequirements": [{
                          "Type": "InferenceAccelerator",
                          "Value": "eia-device-1"
                      }]
                  }
              ],
              "Cpu" : "256",
              "ExecutionRoleArn" : "arn:aws:iam::xxxxxxxxxxxxx:role/ecsTaskExecutionRole",
              "Family" : "TestService",
              "InferenceAccelerators" : [ {
                "DeviceName": "eia-device-1",
                "DeviceType": "eia1.medium"
              } ],
              "Memory" : "512",
              "NetworkMode" : "awsvpc",
              "RequiresCompatibilities" : [ "FARGATE" ],
              "TaskRoleArn" : "arn:aws:iam::xxxxxxxxxxxxx:role/ecsTaskExecutionRole"
            }
        }
    }
}

当我尝试创建堆栈时,cloudformation 失败并出现以下错误:

Invalid request provided: Create TaskDefinition: Unsupported field 'inferenceAccelerators'

然而有两件事对我来说似乎很奇怪:

我做错了什么,这是一个错误,还是出于某种原因任务定义中真的不支持推理加速器?

可能是因为您正在使用 FARGATE 并且 Fargate 不支持 GPU。但支持已经在 AWS 路线图上:

您可以尝试为 EC2 启动类型而不是 Fargate 重新定义您的任务定义和 ecs 服务。

更新

Amazon Elastic Inference 是 only for EC2-type ECS tasks:

This feature is supported when using Linux containers and tasks that use the EC2 launch type.