透過 Hugging Face TGI 在 GKE 上使用 GPU 提供 Gemma 開放式模型


本教學課程說明如何使用 Hugging Face文字生成推論 (TGI) 服務架構,在 Google Kubernetes Engine (GKE) 上透過 GPU 部署及提供大型語言模型 (LLM) 服務。本教學課程提供基礎知識,協助您瞭解及探索如何實際在 Kubernetes 代管環境中部署 LLM,以進行推論。您將執行 TGI 的預先建構容器部署至 GKE。您也可以設定 GKE,從 Hugging Face 載入 Gemma 2B、9B 和 27B 的權重。

本教學課程的適用對象為機器學習 (ML) 工程師、平台管理員和操作員,以及有興趣使用 Kubernetes 容器自動化調度管理功能,在 H100、A100 和 L4 GPU 硬體上提供 LLM 服務的資料和 AI 專家。如要進一步瞭解我們在 Google Cloud 內容中提及的常見角色和範例工作,請參閱「常見的 GKE Enterprise 使用者角色和工作」。

如果您需要整合式代管 AI 平台,以便快速建構及提供機器學習模型,同時兼顧成本效益,建議您試用 Vertex AI 部署解決方案。

閱讀本頁面之前,請先熟悉下列概念:

背景

本節說明本指南中使用的重要技術。

Gemma

Gemma 是一組開放式輕量級生成式人工智慧 (AI) 模型,以開放授權形式發布。您可以在應用程式、硬體、行動裝置或代管服務中執行這些 AI 模型。

本指南將介紹下列模型:

  • Gemma 進行文字生成,您也可以調整這些模型,專門執行特定工作。
  • CodeGemma 是一系列強大輕巧的模型,可執行各種程式設計工作,例如填空式程式碼完成、程式碼生成、自然語言理解、數學推理和指令遵循。

詳情請參閱 Gemma 說明文件

GPU

GPU 可加速處理節點上執行的特定工作負載,例如機器學習和資料處理。GKE 提供各種機器類型選項,可供節點設定使用,包括搭載 NVIDIA H100、L4 和 A100 GPU 的機器類型。

Text Generation Inference (TGI)

TGI 是 Hugging Face 的工具包,可部署及提供 LLM。TGI 可為熱門開放原始碼大型語言模型 (包括 Gemma) 提供高效能的文字生成功能。TGI 包含以下功能:

詳情請參閱 TGI 說明文件

目標

  1. 在 Autopilot 模式中,使用 GKE 叢集準備環境。
  2. 將 TGI 部署至叢集。
  3. 使用 TGI 透過 curl 和網頁聊天介面提供 Gemma 2 模型。

事前準備

  • Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  • In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  • Make sure that billing is enabled for your Google Cloud project.

  • Enable the required API.

    Enable the API

  • In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  • Make sure that billing is enabled for your Google Cloud project.

  • Enable the required API.

    Enable the API

  • Make sure that you have the following role or roles on the project: roles/container.admin, roles/iam.serviceAccountAdmin

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      前往「IAM」頁面
    2. 選取專案。
    3. 按一下「授予存取權」
    4. 在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。

    5. 在「Select a role」(選取角色) 清單中,選取角色。
    6. 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
    7. 按一下 [Save]

取得模型存取權

如要存取 Gemma 模型,以便部署至 GKE,請先簽署授權同意聲明,然後產生 Hugging Face 存取權杖。

您必須簽署同意聲明,才能使用 Gemma。請按照以下步驟操作:

  1. 前往 Kaggle.com 的模型同意聲明頁面
  2. 使用 Hugging Face 帳戶驗證同意聲明。
  3. 接受模型條款。

產生存取權杖

如要透過 Hugging Face 存取模型,必須使用 Hugging Face 權杖

如要產生新權杖 (如果沒有),請按照下列步驟操作:

  1. 依序點選「Your Profile」(你的個人資料) >「Settings」(設定) >「Access Tokens」(存取權杖)
  2. 選取「New Token」
  3. 指定所選名稱和至少 Read 的角色。
  4. 選取「產生權杖」
  5. 將產生的權杖複製到剪貼簿。

準備環境

在本教學課程中,您將使用 Cloud Shell 管理託管於Google Cloud的資源。Cloud Shell 已預先安裝本教學課程所需的軟體,包括 kubectl gcloud CLI

如要使用 Cloud Shell 設定環境,請按照下列步驟操作:

  1. 在 Google Cloud 控制台中,按一下Cloud Shell 啟用圖示Google Cloud 控制台中的「啟用 Cloud Shell」,啟動 Cloud Shell 工作階段。系統會在 Google Cloud 控制台的底部窗格啟動工作階段。

  2. 設定預設環境變數:

    gcloud config set project PROJECT_ID
    gcloud config set billing/quota_project PROJECT_ID
    export PROJECT_ID=$(gcloud config get project)
    export REGION=REGION
    export CLUSTER_NAME=CLUSTER_NAME
    export HF_TOKEN=HF_TOKEN
    

    替換下列值:

    • PROJECT_ID:您的 Google Cloud 專案 ID
    • REGION:支援您要使用的加速器類型,例如 L4 GPU 的 us-central1
    • CLUSTER_NAME:叢集名稱。
    • HF_TOKEN:您先前產生的 Hugging Face 權杖。

建立及設定 Google Cloud 資源

請按照下列操作說明建立必要資源。

建立 GKE 叢集和節點集區

您可以在 GKE Autopilot 或 Standard 叢集的 GPU 上提供 Gemma 服務。建議您使用 Autopilot 叢集,享受全代管 Kubernetes 體驗。如要為工作負載選擇最合適的 GKE 作業模式,請參閱「選擇 GKE 作業模式」。

Autopilot

在 Cloud Shell 中執行下列指令:

gcloud container clusters create-auto CLUSTER_NAME \
    --project=PROJECT_ID \
    --region=REGION \
    --release-channel=rapid

替換下列值:

  • PROJECT_ID:您的 Google Cloud 專案 ID
  • REGION:支援您要使用的加速器類型,例如 L4 GPU 的 us-central1
  • CLUSTER_NAME:叢集名稱。

GKE 會根據部署的工作負載要求,建立含 CPU 和 GPU 節點的 Autopilot 叢集。

標準

  1. 在 Cloud Shell 中執行下列指令,建立 Standard 叢集:

    gcloud container clusters create CLUSTER_NAME \
        --project=PROJECT_ID \
        --region=REGION \
        --workload-pool=PROJECT_ID.svc.id.goog \
        --release-channel=rapid \
        --num-nodes=1
    

    替換下列值:

    • PROJECT_ID:您的 Google Cloud 專案 ID
    • REGION:支援您要使用的加速器類型,例如 L4 GPU 的 us-central1
    • CLUSTER_NAME:叢集名稱。

    建立叢集可能需要幾分鐘的時間。

  2. 如要為叢集建立節點集區,並設定適當的磁碟大小,請執行下列指令:

    Gemma 2 2B

    gcloud container node-pools create gpupool \
        --accelerator type=nvidia-l4,count=1,gpu-driver-version=latest \
        --project=PROJECT_ID \
        --location=REGION \
        --node-locations=REGION-a \
        --cluster=CLUSTER_NAME \
        --machine-type=g2-standard-8 \
        --num-nodes=1
    

    GKE 會為每個節點建立一個包含 L4 GPU 的節點集區。

    Gemma 2 9B

    gcloud container node-pools create gpupool \
        --accelerator type=nvidia-l4,count=2,gpu-driver-version=latest \
        --project=PROJECT_ID \
        --location=REGION \
        --node-locations=REGION-a \
        --cluster=CLUSTER_NAME \
        --machine-type=g2-standard-24 \
        --num-nodes=1
    

    GKE 會為每個節點建立一個節點集區,內含兩個 L4 GPU。

    Gemma 2 27B

    gcloud container node-pools create gpupool \
        --accelerator type=nvidia-l4,count=4,gpu-driver-version=latest \
        --project=PROJECT_ID \
        --location=REGION \
        --node-locations=REGION-a \
        --cluster=CLUSTER_NAME \
        --machine-type=g2-standard-48 \
        --num-nodes=1 \
        --disk-size=180
    

    GKE 會為每個節點建立一個節點集區,內含四個 L4 GPU。

為 Hugging Face 憑證建立 Kubernetes 密鑰

在 Cloud Shell 中執行下列操作:

  1. 設定 kubectl 與叢集通訊:

    gcloud container clusters get-credentials CLUSTER_NAME \
        --location=REGION
    

    替換下列值:

    • REGION:支援您要使用的加速器類型,例如 L4 GPU 的 us-central1
    • CLUSTER_NAME:叢集名稱。
  2. 建立包含 Hugging Face 權杖的 Kubernetes Secret:

    kubectl create secret generic hf-secret \
        --from-literal=hf_api_token=HF_TOKEN \
        --dry-run=client -o yaml | kubectl apply -f -
    

    HF_TOKEN 換成您稍早產生的 Hugging Face 權杖。

部署 TGI

在本節中,您將部署 TGI 容器,提供要使用的 Gemma 模型。本教學課程會使用 Kubernetes Deployment 部署模型。Deployment 是 Kubernetes API 物件,可讓您執行多個 Pod 副本,並將這些副本分散到叢集的節點中。

Gemma 2 2B-it

請按照下列操作說明部署 Gemma 2B 指令微調模型。

  1. 建立下列 tgi-2-2b-it.yaml 資訊清單:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: tgi-gemma-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: gemma-server
      template:
        metadata:
          labels:
            app: gemma-server
            ai.gke.io/model: gemma-2-2b-it
            ai.gke.io/inference-server: text-generation-inference
            examples.ai.gke.io/source: user-guide
        spec:
          containers:
          - name: inference-server
            image: us-docker.pkg.dev/deeplearning-platform-release/gcr.io/huggingface-text-generation-inference-cu124.2-3.ubuntu2204.py311
            resources:
              requests:
                cpu: "2"
                memory: "10Gi"
                ephemeral-storage: "10Gi"
                nvidia.com/gpu: "1"
              limits:
                cpu: "2"
                memory: "10Gi"
                ephemeral-storage: "10Gi"
                nvidia.com/gpu: "1"
            env:
            - name: AIP_HTTP_PORT
              value: '8000'
            - name: NUM_SHARD
              value: '1'
            - name: MAX_INPUT_LENGTH
              value: '1562'
            - name: MAX_TOTAL_TOKENS
              value: '2048'
            - name: MAX_BATCH_PREFILL_TOKENS
              value: '2048'
            - name: CUDA_MEMORY_FRACTION
              value: '0.93'
            - name: MODEL_ID
              value: google/gemma-2-2b-it
            - name: HUGGING_FACE_HUB_TOKEN
              valueFrom:
                secretKeyRef:
                  name: hf-secret
                  key: hf_api_token
            volumeMounts:
            - mountPath: /dev/shm
              name: dshm
          volumes:
          - name: dshm
            emptyDir:
              medium: Memory
          nodeSelector:
            cloud.google.com/gke-accelerator: nvidia-l4
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: llm-service
    spec:
      selector:
        app: gemma-server
      type: ClusterIP
      ports:
      - protocol: TCP
        port: 8000
        targetPort: 8000
  2. 套用資訊清單:

    kubectl apply -f tgi-2-2b-it.yaml
    

Gemma 2 9B-it

請按照下列操作說明部署 Gemma 9B 指令微調模型。

  1. 建立下列 tgi-2-9b-it.yaml 資訊清單:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: tgi-gemma-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: gemma-server
      template:
        metadata:
          labels:
            app: gemma-server
            ai.gke.io/model: gemma-2-9b-it
            ai.gke.io/inference-server: text-generation-inference
            examples.ai.gke.io/source: user-guide
        spec:
          containers:
          - name: inference-server
            image: us-docker.pkg.dev/deeplearning-platform-release/gcr.io/huggingface-text-generation-inference-cu124.2-3.ubuntu2204.py311
            resources:
              requests:
                cpu: "4"
                memory: "30Gi"
                ephemeral-storage: "30Gi"
                nvidia.com/gpu: "2"
              limits:
                cpu: "4"
                memory: "30Gi"
                ephemeral-storage: "30Gi"
                nvidia.com/gpu: "2"
            env:
            - name: AIP_HTTP_PORT
              value: '8000'
            - name: NUM_SHARD
              value: '2'
            - name: MAX_INPUT_LENGTH
              value: '1562'
            - name: MAX_TOTAL_TOKENS
              value: '2048'
            - name: MAX_BATCH_PREFILL_TOKENS
              value: '2048'
            - name: CUDA_MEMORY_FRACTION
              value: '0.93'
            - name: MODEL_ID
              value: google/gemma-2-9b-it
            - name: HUGGING_FACE_HUB_TOKEN
              valueFrom:
                secretKeyRef:
                  name: hf-secret
                  key: hf_api_token
            volumeMounts:
            - mountPath: /dev/shm
              name: dshm
          volumes:
          - name: dshm
            emptyDir:
              medium: Memory
          nodeSelector:
            cloud.google.com/gke-accelerator: nvidia-l4
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: llm-service
    spec:
      selector:
        app: gemma-server
      type: ClusterIP
      ports:
      - protocol: TCP
        port: 8000
        targetPort: 8000
  2. 套用資訊清單:

    kubectl apply -f tgi-2-9b-it.yaml
    

Gemma 2 27B-it

請按照下列操作說明部署 Gemma 2 27B 指令微調模型。

  1. 建立下列 tgi-2-27b-it.yaml 資訊清單:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: tgi-gemma-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: gemma-server
      template:
        metadata:
          labels:
            app: gemma-server
            ai.gke.io/model: gemma-2-27b-it
            ai.gke.io/inference-server: text-generation-inference
            examples.ai.gke.io/source: user-guide
        spec:
          containers:
          - name: inference-server
            image: us-docker.pkg.dev/deeplearning-platform-release/gcr.io/huggingface-text-generation-inference-cu124.2-3.ubuntu2204.py311
            resources:
              requests:
                cpu: "10"
                memory: "80Gi"
                ephemeral-storage: "80Gi"
                nvidia.com/gpu: "4"
              limits:
                cpu: "10"
                memory: "80Gi"
                ephemeral-storage: "80Gi"
                nvidia.com/gpu: "4"
            env:
            - name: AIP_HTTP_PORT
              value: '8000'
            - name: NUM_SHARD
              value: '4'
            - name: MAX_INPUT_LENGTH
              value: '1562'
            - name: MAX_TOTAL_TOKENS
              value: '2048'
            - name: MAX_BATCH_PREFILL_TOKENS
              value: '2048'
            - name: CUDA_MEMORY_FRACTION
              value: '0.93'
            - name: MODEL_ID
              value: google/gemma-2-27b-it
            - name: HUGGING_FACE_HUB_TOKEN
              valueFrom:
                secretKeyRef:
                  name: hf-secret
                  key: hf_api_token
            volumeMounts:
            - mountPath: /dev/shm
              name: dshm
          volumes:
          - name: dshm
            emptyDir:
              medium: Memory
          nodeSelector:
            cloud.google.com/gke-accelerator: nvidia-l4
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: llm-service
    spec:
      selector:
        app: gemma-server
      type: ClusterIP
      ports:
      - protocol: TCP
        port: 8000
        targetPort: 8000
  2. 套用資訊清單:

    kubectl apply -f tgi-2-27b-it.yaml
    

CodeGemma 7B-it

請按照下列操作說明部署 CodeGemma 7B 指令微調模型。

  1. 建立下列 tgi-codegemma-1.1-7b-it.yaml 資訊清單:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: tgi-gemma-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: gemma-server
      template:
        metadata:
          labels:
            app: gemma-server
            ai.gke.io/model: codegemma-1.1-7b-it
            ai.gke.io/inference-server: text-generation-inference
            examples.ai.gke.io/source: user-guide
        spec:
          containers:
          - name: inference-server
            image: us-docker.pkg.dev/deeplearning-platform-release/gcr.io/huggingface-text-generation-inference-cu124.2-3.ubuntu2204.py311
            resources:
              requests:
                cpu: "2"
                memory: "25Gi"
                ephemeral-storage: "40Gi"
                nvidia.com/gpu: 2
              limits:
                cpu: "10"
                memory: "25Gi"
                ephemeral-storage: "40Gi"
                nvidia.com/gpu: 2
            args:
            - --model-id=$(MODEL_ID)
            - --num-shard=2
            env:
            - name: MODEL_ID
              value: google/codegemma-1.1-7b-it
            - name: PORT
              value: "8000"
            - name: HUGGING_FACE_HUB_TOKEN
              valueFrom:
                secretKeyRef:
                  name: hf-secret
                  key: hf_api_token
            volumeMounts:
            - mountPath: /dev/shm
              name: dshm
          volumes:
          - name: dshm
            emptyDir:
              medium: Memory
          nodeSelector:
            cloud.google.com/gke-accelerator: nvidia-l4
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: llm-service
    spec:
      selector:
        app: gemma-server
      type: ClusterIP
      ports:
        - protocol: TCP
          port: 8000
          targetPort: 8000
  2. 套用資訊清單:

    kubectl apply -f tgi-codegemma-1.1-7b-it.yaml
    

提供模型

在本節中,您將與模型互動。

設定通訊埠轉送

執行下列指令,設定模型通訊埠轉送:

kubectl port-forward service/llm-service 8000:8000

輸出結果會與下列內容相似:

Forwarding from 127.0.0.1:8000 -> 8000

使用 curl 與模型互動

本節說明如何執行基本煙霧測試,驗證已部署的預先訓練或指令微調模型。為求簡單起見,本節將說明如何使用 Gemma 2 指令微調和 CodeGemma 模型進行測試。

Gemma 2

在新的終端機工作階段中,使用 curl 與模型對話:

USER_PROMPT="I'm new to coding. If you could only recommend one programming language to start with, what would it be and why?"

curl -X POST http://localhost:8000/generate \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{
    "inputs": "<start_of_turn>user\n${USER_PROMPT}<end_of_turn>\n",
    "parameters": {
        "temperature": 0.90,
        "top_p": 0.95,
        "max_new_tokens": 128
    }
}
EOF

以下輸出內容顯示模型回應的範例:

{"generated_text":"**Python**\n\n**Reasons why Python is a great choice for beginners:**\n\n* **Simple syntax:** Python uses clear and concise syntax, making it easy for beginners to pick up.\n* **Easy to learn:** Python's syntax is based on English, making it easier to learn than other languages.\n* **Large and supportive community:** Python has a massive and active community of developers who are constantly willing to help.\n* **Numerous libraries and tools:** Python comes with a vast collection of libraries and tools that make it easy to perform various tasks, such as data manipulation, web development, and machine learning.\n* **"}

CodeGemma

在新的終端機工作階段中,使用 curl 與模型對話:

USER_PROMPT="Generate a python code example of a adding two numbers from a function called addNumbers"

curl -s -X POST http://localhost:8000/generate \
  -H "Content-Type: application/json" \
  -d @- <<EOF | jq -r .generated_text
{
    "inputs": "<start_of_turn>user\n${USER_PROMPT}<end_of_turn>\n",
    "parameters": {
        "temperature": 0.90,
        "top_p": 0.95,
        "max_new_tokens": 2000
    }
}
EOF

以下輸出內容顯示模型回應的範例:

def addNumbers(num1, num2):
  sum = num1 + num2
  return sum

# Get the input from the user
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))

# Call the addNumbers function
sum = addNumbers(num1, num2)

# Print the result
print("The sum of", num1, "and", num2, "is", sum)

(選用) 透過 Gradio 聊天介面與模型互動

在本節中,您將建構網頁聊天應用程式,與經過指令微調的模型互動。為簡化說明,本節僅介紹使用 2B-it 模型的測試方法。

Gradio 是 Python 程式庫,內含 ChatInterface 包裝函式,可為聊天機器人建立使用者介面。

部署即時通訊介面

  1. 在 Cloud Shell 中,將下列資訊清單儲存為 gradio.yaml

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: gradio
      labels:
        app: gradio
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: gradio
      template:
        metadata:
          labels:
            app: gradio
        spec:
          containers:
          - name: gradio
            image: us-docker.pkg.dev/google-samples/containers/gke/gradio-app:v1.0.4
            resources:
              requests:
                cpu: "250m"
                memory: "512Mi"
              limits:
                cpu: "500m"
                memory: "512Mi"
            env:
            - name: CONTEXT_PATH
              value: "/generate"
            - name: HOST
              value: "http://llm-service:8000"
            - name: LLM_ENGINE
              value: "tgi"
            - name: MODEL_ID
              value: "gemma"
            - name: USER_PROMPT
              value: "<start_of_turn>user\nprompt<end_of_turn>\n"
            - name: SYSTEM_PROMPT
              value: "<start_of_turn>model\nprompt<end_of_turn>\n"
            ports:
            - containerPort: 7860
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: gradio
    spec:
      selector:
        app: gradio
      ports:
      - protocol: TCP
        port: 8080
        targetPort: 7860
      type: ClusterIP
    
  2. 套用資訊清單:

    kubectl apply -f gradio.yaml
    
  3. 等待部署作業完成:

    kubectl wait --for=condition=Available --timeout=300s deployment/gradio
    

使用即時通訊介面

  1. 在 Cloud Shell 中執行下列指令:

    kubectl port-forward service/gradio 8080:8080
    

    這項操作會建立從 Cloud Shell 到 Gradio 服務的通訊埠轉送。

  2. 按一下 Cloud Shell 工作列右上方的「Web Preview」「網頁預覽」圖示按鈕。按一下「透過以下通訊埠預覽:8080」。瀏覽器會開啟新分頁。

  3. 使用 Gradio 對話介面與 Gemma 互動。新增提示,然後按一下「提交」

排解問題

  • 如果收到 Empty reply from server 訊息,表示容器可能尚未完成下載模型資料。再次檢查 Pod 的記錄,確認是否有 Connected 訊息,表示模型已準備好提供服務。
  • 如果看到 Connection refused,請確認連接埠轉送已啟用

觀察模型成效

如要觀察模型效能,您可以在 Cloud Monitoring 中使用 TGI 資訊主頁整合功能。您可以在這個資訊主頁中查看重要成效指標,例如權杖輸送量、要求延遲時間和錯誤率。

如要使用 TGI 資訊主頁,必須在 GKE 叢集中啟用 Google Cloud Managed Service for Prometheus,這個服務會從 TGI 收集指標。TGI 預設會以 Prometheus 格式公開指標,因此您不必安裝額外的匯出工具。

接著,您可以使用 TGI 資訊主頁查看指標。 如要瞭解如何使用 Google Cloud Managed Service for Prometheus 收集模型指標,請參閱 Cloud Monitoring 說明文件中的 TGI 可觀測性指南。

清除所用資源

如要避免系統向您的 Google Cloud 帳戶收取本教學課程中所用資源的相關費用,請刪除含有該項資源的專案,或者保留專案但刪除個別資源。

刪除已部署的資源

如要避免系統向您的 Google Cloud 帳戶收取本指南所建立資源的費用,請執行下列指令:

gcloud container clusters delete CLUSTER_NAME \
    --region=REGION

替換下列值:

  • REGION:支援您要使用的加速器類型,例如 L4 GPU 的 us-central1
  • CLUSTER_NAME:叢集名稱。

後續步驟