GPU-accelerated elastic container instances feature built-in GPUs and Compute Unified Device Architecture (CUDA) drivers. Therefore, when you use a GPU-accelerated elastic container instance, you need to only use a base image that is preinstalled with software such as CUDA Toolkit. You do not need to manually install the GPU driver. This topic describes how to use a GPU-accelerated elastic container instance.

Background information

The GPU driver version supported by GPU-accelerated elastic container instances is NVIDIA 460.73.01. The CUDA Toolkit version supported by GPU-accelerated elastic container instances is 11.2. For more information about CUDA Toolkit, see NVIDIA CUDA.

You can specify GPU-accelerated Elastic Compute Service (ECS) instance types to create GPU-accelerated elastic container instances. The following GPU-accelerated ECS instance types are supported:

  • gn6v, a GPU-accelerated compute-optimized instance family that uses NVIDIA V100 GPUs. This instance family includes a variety of instance types, such as ecs.gn6v-c8g1.2xlarge.
  • gn6i, a GPU-accelerated compute-optimized instance family that uses NVIDIA T4 GPUs. This instance family includes a variety of instance types, such as ecs.gn6i-c4g1.xlarge.
  • gn5, a GPU-accelerated compute-optimized instance family that uses NVIDIA P100 GPUs. This instance family includes a variety of instance types, such as ecs.gn5-c4g1.xlarge.
  • gn5i, a GPU-accelerated compute-optimized instance family that uses NVIDIA P4 GPUs. This instance family includes a variety of instance types, such as ecs.gn5i-c2g1.large.

For more information about GPU-accelerated ECS instance types, see Instance family.

Procedure

Add annotations: k8s.aliyun.com/eci-use-specs to the pod configuration.

  • Specify the instance type that you want to use in the annotations field of the pod metadata.
  • Specify the amount of GPU resources in the resources field of the container configuration.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-gpu-demo
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
      annotations:
        k8s.aliyun.com/eci-use-specs: ecs.gn5i-c4g1.xlarge
    spec:
      containers:
      - name: nginx
        image: registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.15.10
        resources:
            limits:
              nvidia.com/gpu: '1'
        ports:
        - containerPort: 80