All Products
Search
Document Center

Container Service for Kubernetes:Konfigurasikan sumber daya GPU dan aktifkan berbagi GPU untuk Knative

Last Updated:Jun 19, 2026

Deploy beban kerja GPU, seperti inferensi AI dan HPC, pada Knative dengan opsi berbagi GPU antar Pod.

Prasyarat

Konfigurasikan sumber daya GPU

Tambahkan anotasi k8s.aliyun.com/eci-use-specs ke spec.template.metadata.annotations untuk menentukan tipe instans Elastic Compute Service (ECS) yang dipercepat GPU. Tambahkan bidang nvidia.com/gpu ke spec.containers.resources.limits guna mengatur jumlah GPU. Jika Anda menghilangkan nvidia.com/gpu, Pod akan menghasilkan error setelah dimulai.

Contoh Layanan Knative dengan satu GPU:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-go
spec:
  template:
    metadata:
      labels:
        app: helloworld-go
      annotations:
        k8s.aliyun.com/eci-use-specs: ecs.gn5i-c4g1.xlarge  # Tipe instans ECS yang dipercepat GPU
    spec:
      containers:
        - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56
          ports:
          - containerPort: 8080
          resources:
            limits:
              nvidia.com/gpu: '1'    # Jumlah GPU yang dibutuhkan. Bidang wajib.

Keluarga instans GPU yang didukung

Instance family GPU model Example instance type
gn7i NVIDIA A10 ecs.gn7i-c8g1.2xlarge
gn7 ecs.gn7-c12g1.3xlarge
gn6v NVIDIA V100 ecs.gn6v-c8g1.2xlarge
gn6e NVIDIA V100 ecs.gn6e-c12g1.3xlarge
gn6i NVIDIA T4 ecs.gn6i-c4g1.xlarge
gn5i NVIDIA P4 ecs.gn5i-c2g1.large
gn5 NVIDIA P100 ecs.gn5-c4g1.xlarge
Driver GPU yang didukung: NVIDIA 460.73.01. CUDA Toolkit: 11.2. Keluarga gn5 mencakup disk lokal. Untuk memasang disk lokal ke ECI, lihat Buat elastic container instance yang memiliki disk lokal yang disambungkan. Untuk tipe instans yang tersedia berdasarkan wilayah, lihat Tipe instans ECS yang tersedia untuk setiap wilayah dan Ikhtisar keluarga instans.

Aktifkan berbagi GPU

Berbagi GPU memungkinkan beberapa Pod berbagi GPU fisik, sehingga mengurangi biaya ketika beban kerja tidak memerlukan akses GPU eksklusif.

Untuk mengaktifkan berbagi GPU:

  1. Aktifkan GPU sharing untuk node.

  2. Tambahkan bidang aliyun.com/gpu-mem ke spec.containers.resources.limits dalam Layanan Knative Anda untuk mengatur ukuran memori GPU:

    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: helloworld-go
      namespace: default
    spec:
      template:
        metadata:
          annotations:
            autoscaling.knative.dev/maxScale: "100"
            autoscaling.knative.dev/minScale: "0"
        spec:
          containerConcurrency: 1
          containers:
          - image: registry-vpc.cn-hangzhou.aliyuncs.com/hz-suoxing-test/test:helloworld-go
            name: user-container
            ports:
            - containerPort: 6666
              name: http1
              protocol: TCP
            resources:
              limits:
                aliyun.com/gpu-mem: "3"    # Tentukan ukuran memori GPU.

Langkah berikutnya