Create an ECI pod with a GPU-accelerated ECS instance type and customize the GPU driver version.
Supported instance types
For more information about ECS instance types, see the following topics:
Configure a GPU pod
Add the k8s.aliyun.com/eci-use-specs annotation to the pod metadata to specify a GPU instance type. Each container must also declare the nvidia.com/gpu field in its resources section.
-
The
nvidia.com/gpufield specifies the number of GPUs required by the container. This field is required. Pod creation fails without it. -
Multiple containers share GPUs by default. The GPU count for a single container must not exceed the total GPUs of the specified instance type.
Sample YAML:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
name: nginx-test
labels:
app: nginx
alibabacloud.com/eci: "true"
annotations:
# Specify up to five GPU-accelerated ECS instance types at a time, separated by commas.
# The system selects the first available type from the list.
k8s.aliyun.com/eci-use-specs: "ecs.gn6i-c4g1.xlarge,ecs.gn6i-c8g1.2xlarge"
spec:
containers:
- name: nginx
image: registry-us-east-1.aliyuncs.com/eci_open/nginx:1.14.2
resources:
limits:
nvidia.com/gpu: "1" # Request 1 GPU for this container (GPUs are shared by default).
ports:
- containerPort: 80
- name: busybox
image: registry-us-east-1.aliyuncs.com/eci_open/busybox:1.30
command: ["sleep"]
args: ["999999"]
resources:
limits:
nvidia.com/gpu: "1" # Request 1 GPU for this container (GPUs are shared by default).
ECI automatically installs a default GPU driver and CUDA version based on the specified instance type. To use a different driver version, add the k8s.aliyun.com/eci-gpu-driver-version annotation.
For example, the ecs.gn6i-c4g1.xlarge instance type defaults to Tesla 550 with CUDA 12.4. Adding the k8s.aliyun.com/eci-gpu-driver-version: tesla=535 annotation switches to Tesla 535 with CUDA 12.2. Sample YAML:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
name: nginx-test
labels:
app: nginx
alibabacloud.com/eci: "true"
annotations:
# Specify a supported GPU instance type that allows you to change the driver version.
k8s.aliyun.com/eci-use-specs: ecs.gn6i-c4g1.xlarge
# Override the default driver version (Tesla 550) with Tesla 535.
k8s.aliyun.com/eci-gpu-driver-version: tesla=535
spec:
containers:
- name: nginx
image: registry-us-east-1.aliyuncs.com/eci_open/nginx:1.14.2
resources:
limits:
nvidia.com/gpu: "1" # Request 1 GPU for this container.