Hugging Face TGI로 GKE에서 GPU를 사용하여 Gemma 개방형 모델 제공


이 튜토리얼에서는 Hugging Face텍스트 생성 추론(TGI) 제공 프레임워크와 Google Kubernetes Engine(GKE)의 그래픽 처리 장치(GPU)를 사용하여 Gemma 대규모 언어 모델(LLM)을 제공하는 방법을 보여줍니다. 이 튜토리얼에서는 Hugging Face에서 2B 및 7B 매개변수가 선행 학습되고 명령 조정된 Gemma 모델을 다운로드하고 TGI를 실행하는 컨테이너를 사용하여 GKE Autopilot 또는 Standard 클러스터에 배포합니다.

이 가이드는 AI/ML 워크로드를 배포하고 제공할 때 관리형 Kubernetes의 세밀한 제어, 확장성, 복원력, 이동성, 비용 효율성이 필요한 경우 좋은 출발점이 될 수 있습니다. ML 모델을 비용 효율적으로 빠르게 빌드하고 제공할 수 있는 통합 관리형 AI 플랫폼이 필요한 경우 Vertex AI 배포 솔루션을 사용하는 것이 좋습니다.

배경

TGI와 함께 GKE에서 GPU를 사용하여 Gemma를 제공하면 효율적인 확장성 및 더 높은 가용성을 비롯하여 관리형 Kubernetes의 모든 이점을 갖춘 강력한 프로덕션에 즉시 사용 가능한 추론 제공 솔루션을 구현할 수 있습니다. 이 섹션에서는 이 가이드에서 사용되는 주요 기술을 설명합니다.

Gemma

Gemma는 오픈 라이선스로 출시된 공개적으로 사용 가능한 가벼운 생성형 인공지능(AI) 모델의 집합입니다. 이러한 AI 모델은 애플리케이션, 하드웨어, 휴대기기 또는 호스팅된 서비스에서 실행할 수 있습니다. 텍스트 생성에 Gemma 모델을 사용할 수 있지만 특수한 태스크를 위해 이러한 모델을 조정할 수도 있습니다.

자세한 내용은 Gemma 문서를 참조하세요.

GPU

GPU를 사용하면 머신러닝 및 데이터 처리와 같이 노드에서 실행되는 특정 워크로드를 가속화할 수 있습니다. GKE는 NVIDIA H100, L4, A100 GPU가 있는 머신 유형을 포함하여 노드 구성에 사용되는 다양한 머신 유형 옵션을 제공합니다.

GKE에서 GPU를 사용하기 전에 다음 학습 과정을 완료하는 것이 좋습니다.

  1. 현재 GPU 버전 가용성 알아보기
  2. GKE의 GPU 알아보기

텍스트 생성 추론(TGI)

TGI는 LLM을 배포하고 제공하기 위한 Hugging Face의 툴킷입니다. TGI는 Gemma를 포함하여 인기 있는 오픈소스 LLM에 대한 고성능 텍스트 생성을 지원합니다. TGI에는 다음과 같은 기능이 포함됩니다.

자세한 내용은 TGI 문서를 참조하세요.

목표

이 가이드는 PyTorch를 사용하는 생성형 AI 고객, GKE의 신규 또는 기존 사용자, ML 엔지니어, MLOps(DevOps) 엔지니어, H100, A100, L4 GPU 하드웨어에서 LLM을 제공하기 위해 Kubernetes 컨테이너 조정 기능을 사용하는 데 관심이 있는 플랫폼 관리자를 대상으로 합니다.

이 가이드를 마치면 다음 단계를 수행할 수 있습니다.

  1. Autopilot 모드의 GKE 클러스터로 환경을 준비합니다.
  2. 클러스터에 TGI를 배포합니다.
  3. TGI를 사용하여 curl 및 웹 채팅 인터페이스를 통해 Gemma 2B 또는 7B 모델을 처리합니다.

시작하기 전에

  • Google Cloud 계정에 로그인합니다. Google Cloud를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
  • Google Cloud Console의 프로젝트 선택기 페이지에서 Google Cloud 프로젝트를 선택하거나 만듭니다.

    프로젝트 선택기로 이동

  • Google Cloud 프로젝트에 결제가 사용 설정되어 있는지 확인합니다.

  • 필요한 API를 사용 설정합니다.

    API 사용 설정

  • Google Cloud Console의 프로젝트 선택기 페이지에서 Google Cloud 프로젝트를 선택하거나 만듭니다.

    프로젝트 선택기로 이동

  • Google Cloud 프로젝트에 결제가 사용 설정되어 있는지 확인합니다.

  • 필요한 API를 사용 설정합니다.

    API 사용 설정

  • 프로젝트에 다음 역할이 있는지 확인합니다. roles/container.admin, roles/iam.serviceAccountAdmin

    역할 확인

    1. Google Cloud 콘솔에서 IAM 페이지로 이동합니다.

      IAM으로 이동
    2. 프로젝트를 선택합니다.
    3. 주 구성원 열에서 이메일 주소가 있는 행을 찾습니다.

      이메일 주소가 열에 없으면 역할이 없는 것입니다.

    4. 이메일 주소가 있는 행에 대해 역할 열에서 역할 목록에 필요한 역할이 있는지 확인합니다.

    역할 부여

    1. Google Cloud 콘솔에서 IAM 페이지로 이동합니다.

      IAM으로 이동
    2. 프로젝트를 선택합니다.
    3. 액세스 권한 부여를 클릭합니다.
    4. 새 주 구성원 필드에 이메일 주소를 입력합니다.
    5. 역할 선택 목록에서 역할을 선택합니다.
    6. 역할을 추가로 부여하려면 다른 역할 추가를 클릭하고 각 역할을 추가합니다.
    7. 저장을 클릭합니다.

모델 액세스 권한 얻기

GKE에 배포하기 위해 Gemma 모델에 액세스하려면 먼저 라이선스 동의 계약에 서명한 다음 Hugging Face 액세스 토큰을 생성해야 합니다.

Gemma를 사용하려면 동의 계약에 서명해야 합니다. 다음 안내를 따르세요.

  1. Kaggle.com의 모델 동의 페이지에 액세스합니다.
  2. Hugging Face 계정을 사용하여 동의를 확인합니다.
  3. 모델 약관에 동의합니다.

액세스 토큰 생성

Hugging Face를 통해 모델에 액세스하려면 Hugging Face 토큰이 필요합니다.

아직 토큰이 없으면 다음 단계에 따라 새 토큰을 생성합니다.

  1. 내 프로필 > 설정 > 액세스 토큰을 클릭합니다.
  2. 새 토큰을 선택합니다.
  3. 원하는 이름과 Read 이상의 역할을 지정합니다.
  4. 토큰 생성을 선택합니다.
  5. 클립보드에 생성된 토큰을 복사합니다.

개발 환경 준비

이 튜토리얼에서는 Cloud Shell을 사용하여 Google Cloud에서 호스팅되는 리소스를 관리합니다. Cloud Shell에는 kubectlgcloud CLI를 포함하여 이 튜토리얼에 필요한 소프트웨어가 사전 설치되어 있습니다.

Cloud Shell로 환경을 설정하려면 다음 단계를 따르세요.

  1. Google Cloud 콘솔의 Google Cloud 콘솔에서 Cloud Shell 활성화 아이콘 Cloud Shell 활성화를 클릭하여 Cloud Shell 세션을 시작합니다. 그러면 Google Cloud 콘솔 하단 창에서 세션이 시작됩니다.

  2. 기본 환경 변수를 설정합니다.

    gcloud config set project PROJECT_ID
    export PROJECT_ID=$(gcloud config get project)
    export REGION=REGION
    export CLUSTER_NAME=tgi
    export HF_TOKEN=HF_TOKEN
    

    다음 값을 바꿉니다.

    • PROJECT_ID: Google Cloud 프로젝트 ID입니다.
    • REGION: 사용하려는 가속기 유형을 지원하는 리전(예: L4 GPU의 경우 us-central1)입니다.
    • HF_TOKEN: 앞에서 생성한 Hugging Face 토큰입니다.

Google Cloud 리소스 만들기 및 구성

다음 안내에 따라 필요한 리소스를 만듭니다.

GKE 클러스터 및 노드 풀 만들기

GKE Autopilot 또는 Standard 클러스터의 GPU에 Gemma를 제공할 수 있습니다. 완전 관리형 Kubernetes 환경에서는 Autopilot 클러스터를 사용하는 것이 좋습니다. 워크로드에 가장 적합한 GKE 작업 모드를 선택하려면 GKE 작업 모드 선택을 참조하세요.

Autopilot

Cloud Shell에서 다음 명령어를 실행합니다.

gcloud container clusters create-auto ${CLUSTER_NAME} \
  --project=${PROJECT_ID} \
  --region=${REGION} \
  --release-channel=rapid \
  --cluster-version=1.28

GKE는 배포된 워크로드의 요청에 따라 CPU 및 GPU 노드를 사용하여 Autopilot 클러스터를 만듭니다.

Standard

  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
    

    클러스터 만들기는 몇 분 정도 걸릴 수 있습니다.

  2. 다음 명령어를 실행하여 클러스터의 노드 풀을 만듭니다.

    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는 각 노드에 대해 2개의 L4 GPU를 포함하는 단일 노드 풀을 만듭니다.

Hugging Face 사용자 인증 정보용 Kubernetes 보안 비밀 만들기

Cloud Shell에서 다음을 수행합니다.

  1. 클러스터와 통신하도록 kubectl을 구성합니다.

    gcloud container clusters get-credentials ${CLUSTER_NAME} --location=${REGION}
    
  2. Hugging Face 토큰이 포함된 Kubernetes 보안 비밀을 만듭니다.

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

TGI 배포

이 섹션에서는 사용하려는 Gemma 모델을 제공하기 위해 TGI 컨테이너를 배포합니다. 조정 및 선행 학습된 모델과 사용 사례에 선택할 수 있는 안내에 대해 자세히 알아보려면 조정된 모델을 참조하세요.

Gemma 2B-it

다음 안내에 따라 Gemma 2B 명령 조정 모델을 배포합니다.

  1. 다음 tgi-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-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/vertex-ai/vertex-vision-model-garden-dockers/pytorch-hf-tgi-serve:20240220_0936_RC01
            resources:
              requests:
                cpu: "2"
                memory: "7Gi"
                ephemeral-storage: "20Gi"
                nvidia.com/gpu: 1
              limits:
                cpu: "2"
                memory: "7Gi"
                ephemeral-storage: "20Gi"
                nvidia.com/gpu: 1
            args:
            - --model-id=$(MODEL_ID)
            - --num-shard=1
            env:
            - name: MODEL_ID
              value: google/gemma-2b-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-2b-it.yaml
    

Gemma 7B-it

다음 안내에 따라 Gemma 7B 명령 조정 모델을 배포합니다.

  1. 다음 tgi-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: gemma-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/vertex-ai/vertex-vision-model-garden-dockers/pytorch-hf-tgi-serve:20240220_0936_RC01
            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/gemma-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-7b-it.yaml
    

Gemma 2B

다음 안내에 따라 Gemma 2B 선행 학습된 모델을 배포합니다.

  1. 다음 tgi-2b.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-2b
            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/vertex-ai/vertex-vision-model-garden-dockers/pytorch-hf-tgi-serve:20240220_0936_RC01
            resources:
              requests:
                cpu: "2"
                memory: "7Gi"
                ephemeral-storage: "20Gi"
                nvidia.com/gpu: 1
              limits:
                cpu: "2"
                memory: "7Gi"
                ephemeral-storage: "20Gi"
                nvidia.com/gpu: 1
            args:
            - --model-id=$(MODEL_ID)
            - --num-shard=1
            env:
            - name: MODEL_ID
              value: google/gemma-2b
            - 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-2b.yaml
    

Gemma 7B

다음 안내에 따라 Gemma 2B 선행 학습된 모델을 배포합니다.

  1. 다음 tgi-7b.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-7b
            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/vertex-ai/vertex-vision-model-garden-dockers/pytorch-hf-tgi-serve:20240220_0936_RC01
            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/gemma-7b
            - 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-7b.yaml
    

클러스터의 포드가 Hugging Face의 모델 가중치를 다운로드하고 제공 엔진을 시작합니다.

배포를 사용할 수 있을 때까지 기다립니다.

kubectl wait --for=condition=Available --timeout=700s deployment/tgi-gemma-deployment

실행 중인 배포의 로그를 봅니다.

kubectl logs -f -l app=gemma-server

배포 리소스는 모델 데이터를 다운로드합니다. 이 프로세스는 몇 분 정도 걸릴 수 있습니다. 출력은 다음과 비슷합니다.

INFO text_generation_router: router/src/main.rs:237: Using the Hugging Face API to retrieve tokenizer config
INFO text_generation_router: router/src/main.rs:280: Warming up model
INFO text_generation_router: router/src/main.rs:316: Setting max batch total tokens to 666672
INFO text_generation_router: router/src/main.rs:317: Connected
WARN text_generation_router: router/src/main.rs:331: Invalid hostname, defaulting to 0.0.0.0
INFO text_generation_router::server: router/src/server.rs:1035: Built with `google` feature
INFO text_generation_router::server: router/src/server.rs:1036: Environment variables `AIP_PREDICT_ROUTE` and `AIP_HEALTH_ROUTE` will be respected.

다음 섹션으로 이동하기 전에 모델이 완전히 다운로드되었는지 확인합니다.

모델 제공

이 섹션에서는 모델과 상호작용합니다.

포트 전달 설정

다음 명령어를 실행하여 모델에 대한 포트 전달을 설정합니다.

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

출력은 다음과 비슷합니다.

Forwarding from 127.0.0.1:8000 -> 8000

curl을 사용하여 모델과 상호작용

이 섹션에서는 기본 스모크 테스트를 수행하여 배포된 사전 학습 또는 명령 조정 모델을 확인하는 방법을 보여줍니다. 편의를 위해 이 섹션에서는 2B 선행 학습 및 명령 조정 모델만 사용하는 테스트 접근 방식을 설명합니다.

선행 학습(2B)

새 터미널 세션에서 curl을 사용해서 모델과 채팅합니다.

USER_PROMPT="Java is a"

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

다음 출력에는 모델 응답 예시가 표시됩니다.

{"generated_text":" general-purpose, high-level, class-based, object-oriented programming language. <strong>Is Java a statically typed language?</strong> Yes, Java is a statically typed language. Java also supports dynamic typing. Static typing means that the type of every variable is explicitly specified at the time of declaration. The type can be either implicit or explicit. Static typing means that if no types are assigned then it will be assumed as a primitive type.\n\n<h3>What is Java?</h3>\n\nJava is a general-purpose, class-based, object-oriented programming language. Java is one of the oldest programming languages that has gained a"}

명령 조정(2B-it)

새 터미널 세션에서 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* **"}

(선택사항) GRadio 채팅 인터페이스를 통해 모델과 상호작용

이 섹션에서는 명령 조정 모델과 상호작용할 수 있는 웹 채팅 애플리케이션을 빌드합니다. 편의를 위해 이 섹션에서는 2B-it 모델을 사용한 테스트 접근 방식만 설명합니다.

Gradio는 챗봇용 사용자 인터페이스를 만드는 ChatInterface 래퍼가 있는 Python 라이브러리입니다.

채팅 인터페이스 배포

  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.0
            resources:
              requests:
                cpu: "512m"
                memory: "512Mi"
              limits:
                cpu: "1"
                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 작업 표시줄의 오른쪽 상단에 있는 웹 미리보기 아이콘 웹 미리보기 버튼을 클릭합니다. 포트 8080에서 미리보기를 클릭합니다. 브라우저에 새 탭이 열립니다.

  3. GRadio 채팅 인터페이스를 사용하여 Gemma와 상호작용합니다. 프롬프트를 추가하고 제출을 클릭합니다.

문제 해결하기

  • Empty reply from server 메시지가 표시되면 컨테이너에서 모델 데이터 다운로드가 완료되지 않았을 수 있습니다. 모델을 제공할 준비가 되었음을 나타내는 Connected 메시지가 있는지 포드의 로그를 다시 확인합니다.
  • Connection refused가 표시되면 포트 전달이 활성 상태인지 확인합니다.

삭제

이 튜토리얼에서 사용된 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 리소스가 포함된 프로젝트를 삭제하거나 프로젝트를 유지하고 개별 리소스를 삭제하세요.

배포된 리소스 삭제

이 가이드에서 만든 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 명령어를 실행합니다.

gcloud container clusters delete ${CLUSTER_NAME} \
  --region=${REGION}

다음 단계