Model Garden 및 Vertex AI GPU 지원 엔드포인트를 사용하여 Gemma 배포 및 추론


이 튜토리얼에서는 Model Garden을 사용하여 GPU 지원 Vertex AI 엔드포인트에 Gemma 2B 개방형 모델을 배포합니다. 모델을 온라인 예측을 제공하는 데 사용하려면 먼저 엔드포인트에 모델을 배포해야 합니다. 모델을 배포하면 물리적 리소스가 모델과 연결되므로 짧은 지연 시간으로 온라인 예측을 제공할 수 있습니다.

Gemma 2B 모델을 배포한 후 PredictionServiceClient를 사용하여 온라인 예측을 가져와 학습된 모델을 추론합니다. 온라인 예측은 엔드포인트에 배포된 모델에 수행되는 동기식 요청입니다.

목표

이 튜토리얼에서는 다음 작업을 수행하는 방법을 보여줍니다.

  • Model Garden을 사용하여 GPU 지원 엔드포인트에 Gemma 2B 개방형 모델 배포
  • PredictionServiceClient를 사용하여 온라인 예측 수행

비용

이 문서에서는 비용이 청구될 수 있는 다음과 같은 Google Cloud 구성요소를 사용합니다.

프로젝트 사용량을 기준으로 예상 비용을 산출하려면 가격 계산기를 사용하세요. Google Cloud를 처음 사용하는 사용자는 무료 체험판을 사용할 수 있습니다.

이 문서에 설명된 태스크를 완료했으면 만든 리소스를 삭제하여 청구가 계속되는 것을 방지할 수 있습니다. 자세한 내용은 삭제를 참조하세요.

시작하기 전에

이 튜토리얼을 완료하려면 다음이 필요합니다.

  • Google Cloud 프로젝트를 설정하고 Vertex AI API를 사용 설정합니다.
  • 로컬 머신에서 다음 단계를 따르세요.
    • Google Cloud CLI로 설치, 초기화, 인증
    • 사용 언어의 SDK 설치

Google Cloud 프로젝트 설정

프로젝트를 설정하고 Google Cloud Vertex AI API를 사용 설정합니다.

  1. 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.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

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

  4. Enable the Vertex AI API.

    Enable the API

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

    Go to project selector

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

  7. Enable the Vertex AI API.

    Enable the API

Google Cloud CLI 설정

로컬 머신에서 Google Cloud CLI를 설정합니다.

  1. Google Cloud CLI를 설치하고 초기화합니다.

  2. 이전에 gcloud CLI를 설치한 경우 이 명령어를 실행하여 gcloud 구성요소가 업데이트되었는지 확인합니다.

    gcloud components update
  3. gcloud CLI로 인증하려면 이 명령어를 실행하여 로컬 애플리케이션 기본 사용자 인증 정보 (ADC) 파일을 생성합니다. 명령어로 실행된 웹 흐름은 사용자 인증 정보를 제공하는 데 사용됩니다.

    gcloud auth application-default login

    자세한 내용은 gcloud CLI 인증 구성 및 ADC 구성을 참고하세요.

프로그래밍 언어의 SDK 설정

이 튜토리얼에서 사용되는 환경을 설정하려면 언어의 Vertex AI SDK와 Protocol Buffers 라이브러리를 설치합니다. 코드 샘플은 프로토콜 버퍼 라이브러리의 함수를 사용하여 입력 사전을 API에서 예상하는 JSON 형식으로 변환합니다.

로컬 머신에서 다음 탭 중 하나를 클릭하여 프로그래밍 언어의 SDK를 설치합니다.

Python

로컬 머신에서 다음 탭 중 하나를 클릭하여 프로그래밍 언어의 SDK를 설치합니다.

  • 이 명령어를 실행하여 Vertex AI SDK for Python을 설치하고 업데이트합니다.

    pip3 install --upgrade "google-cloud-aiplatform>=1.64"
  • 이 명령어를 실행하여 Python용 Protocol Buffers 라이브러리를 설치합니다.

    pip3 install --upgrade "protobuf>=5.28"

Node.js

다음 명령어를 실행하여 Node.js용 aiplatform SDK를 설치하거나 업데이트합니다.

npm install @google-cloud/aiplatform

자바

google-cloud-aiplatform를 종속 항목으로 추가하려면 환경에 적절한 코드를 추가합니다.

BOM이 있는 Maven

pom.xml에 다음 HTML을 추가합니다.

<dependencyManagement>
<dependencies>
  <dependency>
    <artifactId>libraries-bom</artifactId>
    <groupId>com.google.cloud</groupId>
    <scope>import</scope>
    <type>pom</type>
    <version>26.34.0</version>
  </dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-aiplatform</artifactId>
</dependency>
<dependency>
  <groupId>com.google.protobuf</groupId>
  <artifactId>protobuf-java-util</artifactId>
</dependency>
<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
</dependency>
</dependencies>

BOM이 없는 Maven

pom.xml에 다음을 추가합니다.

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-aiplatform</artifactId>
  <version>1.1.0</version>
</dependency>
<dependency>
  <groupId>com.google.protobuf</groupId>
  <artifactId>protobuf-java-util</artifactId>
  <version>5.28</version>
</dependency>
<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.11.0</version>
</dependency>

BOM이 없는 Gradle

build.gradle에 다음을 추가합니다.

implementation 'com.google.cloud:google-cloud-aiplatform:1.1.0'

Go

다음 명령어를 실행하여 이러한 Go 패키지를 설치합니다.

go get cloud.google.com/go/aiplatform
go get google.golang.org/protobuf
go get github.com/googleapis/gax-go/v2

Model Garden을 사용하여 Gemma 배포

Gemma 2B 모델을 g2-standard-12 Compute Engine 가속기 최적화 머신 유형에 배포합니다. 이 머신에는 NVIDIA L4 GPU 가속기 1개가 연결되어 있습니다.

이 튜토리얼에서는 Model Garden의 모델 카드를 사용하여 명령어 조정된 Gemma 2B 공개 모델을 배포합니다. 특정 모델 버전은 gemma2-2b-it입니다. -it명령어 조정을 나타냅니다.

Gemma 2B 모델은 매개변수 크기가 작으므로 리소스 요구사항이 적고 배포 유연성이 높습니다.

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

    Model Garden으로 이동

  2. Gemma 2 모델 카드를 클릭합니다.

    Gemma 2로 이동

  3. 배포를 클릭하여 모델 배포 창을 엽니다.

  4. 모델 배포 창에서 다음 세부정보를 지정합니다.

    1. 배포 환경에서 Vertex AI를 클릭합니다.

    2. 모델 배포 섹션에서 다음을 수행합니다.

      1. 리소스 IDgemma-2b-it를 선택합니다.

      2. 모델 이름엔드포인트 이름의 경우 기본값을 사용합니다. 예를 들면 다음과 같습니다.

        • 모델 이름: gemma2-2b-it-1234567891234
        • 엔드포인트 이름: gemma2-2b-it-mg-one-click-deploy

        엔드포인트 이름을 기록해 둡니다. 코드 샘플에 사용된 엔드포인트 ID를 찾으려면 이 ID가 필요합니다.

    3. 배포 설정 섹션에서 다음을 수행합니다.

      1. 기본 설정의 기본 옵션을 수락합니다.

      2. 리전의 경우 기본값을 사용하거나 목록에서 리전을 선택합니다. 리전을 기록해 둡니다. 코드 샘플에 필요합니다.

      3. 머신 사양에서 GPU 지원 인스턴스(1 NVIDIA_L4 g2-standard-12)를 선택합니다.

  5. 배포를 클릭합니다. 배포가 완료되면 새 엔드포인트에 관한 세부정보가 포함된 이메일이 전송됩니다. 온라인 예측 > 엔드포인트를 클릭하고 리전을 선택하여 엔드포인트 세부정보를 볼 수도 있습니다.

    엔드포인트로 이동

PredictionServiceClient로 Gemma 2B 추론

Gemma 2B를 배포한 후 PredictionServiceClient를 사용하여 '하늘은 왜 파랗지?'라는 프롬프트에 대한 온라인 예측을 가져옵니다.

코드 매개변수

PredictionServiceClient 코드 샘플을 사용하려면 다음을 업데이트해야 합니다.

  • PROJECT_ID: 프로젝트 ID를 찾으려면 다음 단계를 따르세요.

    1. Google Cloud 콘솔에서 시작하기 페이지로 이동합니다.

      시작하기로 이동

    2. 페이지 상단의 프로젝트 선택기에서 프로젝트를 선택합니다.

      프로젝트 이름, 프로젝트 번호, 프로젝트 ID가 시작하기 제목 뒤에 표시됩니다.

  • ENDPOINT_REGION: 엔드포인트를 배포한 리전입니다.

  • ENDPOINT_ID: 엔드포인트 ID를 찾으려면 콘솔에서 확인하거나 gcloud ai endpoints list 명령어를 실행합니다. 모델 배포 창의 엔드포인트 이름과 리전이 필요합니다.

    콘솔

    온라인 예측 > 엔드포인트를 클릭하고 리전을 선택하여 엔드포인트 세부정보를 볼 수 있습니다. ID 열에 표시되는 번호를 확인합니다.

    엔드포인트로 이동

    gcloud

    gcloud ai endpoints list 명령어를 실행하여 엔드포인트 세부정보를 볼 수 있습니다.

    gcloud ai endpoints list \
      --region=ENDPOINT_REGION \
      --filter=display_name=ENDPOINT_NAME
    

    출력은 다음과 같습니다.

    Using endpoint [https://us-central1-aiplatform.googleapis.com/]
    ENDPOINT_ID: 1234567891234567891
    DISPLAY_NAME: gemma2-2b-it-mg-one-click-deploy
    

샘플 코드

언어의 샘플 코드에서 PROJECT_ID, ENDPOINT_REGION, ENDPOINT_ID를 업데이트합니다. 그런 다음 코드를 실행합니다.

Python용 Vertex AI SDK

Python용 Vertex AI SDK를 설치하거나 업데이트하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python용 Vertex AI SDK API 참조 문서를 확인하세요.

"""
Sample to run inference on a Gemma2 model deployed to a Vertex AI endpoint with GPU accellerators.
"""

from google.cloud import aiplatform
from google.protobuf import json_format
from google.protobuf.struct_pb2 import Value

# TODO(developer): Update & uncomment lines below
# PROJECT_ID = "your-project-id"
# ENDPOINT_REGION = "your-vertex-endpoint-region"
# ENDPOINT_ID = "your-vertex-endpoint-id"

# Default configuration
config = {"max_tokens": 1024, "temperature": 0.9, "top_p": 1.0, "top_k": 1}

# Prompt used in the prediction
prompt = "Why is the sky blue?"

# Encapsulate the prompt in a correct format for GPUs
# Example format: [{'inputs': 'Why is the sky blue?', 'parameters': {'temperature': 0.9}}]
input = {"inputs": prompt, "parameters": config}

# Convert input message to a list of GAPIC instances for model input
instances = [json_format.ParseDict(input, Value())]

# Create a client
api_endpoint = f"{ENDPOINT_REGION}-aiplatform.googleapis.com"
client = aiplatform.gapic.PredictionServiceClient(
    client_options={"api_endpoint": api_endpoint}
)

# Call the Gemma2 endpoint
gemma2_end_point = (
    f"projects/{PROJECT_ID}/locations/{ENDPOINT_REGION}/endpoints/{ENDPOINT_ID}"
)
response = client.predict(
    endpoint=gemma2_end_point,
    instances=instances,
)
text_responses = response.predictions
print(text_responses[0])

Node.js

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Node.js 설정 안내를 따르세요. 자세한 내용은 Vertex AI Node.js API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

async function gemma2PredictGpu(predictionServiceClient) {
  // Imports the Google Cloud Prediction Service Client library
  const {
    // TODO(developer): Uncomment PredictionServiceClient before running the sample.
    // PredictionServiceClient,
    helpers,
  } = require('@google-cloud/aiplatform');
  /**
   * TODO(developer): Update these variables before running the sample.
   */
  const projectId = 'your-project-id';
  const endpointRegion = 'your-vertex-endpoint-region';
  const endpointId = 'your-vertex-endpoint-id';

  // Default configuration
  const config = {maxOutputTokens: 1024, temperature: 0.9, topP: 1.0, topK: 1};
  // Prompt used in the prediction
  const prompt = 'Why is the sky blue?';

  // Encapsulate the prompt in a correct format for GPUs
  // Example format: [{inputs: 'Why is the sky blue?', parameters: {temperature: 0.9}}]
  const input = {
    inputs: prompt,
    parameters: config,
  };

  // Convert input message to a list of GAPIC instances for model input
  const instances = [helpers.toValue(input)];

  // TODO(developer): Uncomment apiEndpoint and predictionServiceClient before running the sample.
  // const apiEndpoint = `${endpointRegion}-aiplatform.googleapis.com`;

  // Create a client
  // predictionServiceClient = new PredictionServiceClient({apiEndpoint});

  // Call the Gemma2 endpoint
  const gemma2Endpoint = `projects/${projectId}/locations/${endpointRegion}/endpoints/${endpointId}`;

  const [response] = await predictionServiceClient.predict({
    endpoint: gemma2Endpoint,
    instances,
  });

  const predictions = response.predictions;
  const text = predictions[0].stringValue;

  console.log('Predictions:', text);
  return text;
}

module.exports = gemma2PredictGpu;

// TODO(developer): Uncomment below lines before running the sample.
// gemma2PredictGpu(...process.argv.slice(2)).catch(err => {
//   console.error(err.message);
//   process.exitCode = 1;
// });

Java

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Java 설정 안내를 따르세요. 자세한 내용은 Vertex AI Java API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


import com.google.cloud.aiplatform.v1.EndpointName;
import com.google.cloud.aiplatform.v1.PredictResponse;
import com.google.cloud.aiplatform.v1.PredictionServiceClient;
import com.google.cloud.aiplatform.v1.PredictionServiceSettings;
import com.google.gson.Gson;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Value;
import com.google.protobuf.util.JsonFormat;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Gemma2PredictGpu {

  private final PredictionServiceClient predictionServiceClient;

  // Constructor to inject the PredictionServiceClient
  public Gemma2PredictGpu(PredictionServiceClient predictionServiceClient) {
    this.predictionServiceClient = predictionServiceClient;
  }

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String endpointRegion = "us-east4";
    String endpointId = "YOUR_ENDPOINT_ID";

    PredictionServiceSettings predictionServiceSettings =
        PredictionServiceSettings.newBuilder()
            .setEndpoint(String.format("%s-aiplatform.googleapis.com:443", endpointRegion))
            .build();
    PredictionServiceClient predictionServiceClient =
        PredictionServiceClient.create(predictionServiceSettings);
    Gemma2PredictGpu creator = new Gemma2PredictGpu(predictionServiceClient);

    creator.gemma2PredictGpu(projectId, endpointRegion, endpointId);
  }

  // Demonstrates how to run inference on a Gemma2 model
  // deployed to a Vertex AI endpoint with GPU accelerators.
  public String gemma2PredictGpu(String projectId, String region,
               String endpointId) throws IOException {
    Map<String, Object> paramsMap = new HashMap<>();
    paramsMap.put("temperature", 0.9);
    paramsMap.put("maxOutputTokens", 1024);
    paramsMap.put("topP", 1.0);
    paramsMap.put("topK", 1);
    Value parameters = mapToValue(paramsMap);

    // Prompt used in the prediction
    String instance = "{ \"inputs\": \"Why is the sky blue?\"}";
    Value.Builder instanceValue = Value.newBuilder();
    JsonFormat.parser().merge(instance, instanceValue);
    // Encapsulate the prompt in a correct format for GPUs
    // Example format: [{'inputs': 'Why is the sky blue?', 'parameters': {'temperature': 0.8}}]
    List<Value> instances = new ArrayList<>();
    instances.add(instanceValue.build());

    EndpointName endpointName = EndpointName.of(projectId, region, endpointId);

    PredictResponse predictResponse = this.predictionServiceClient
        .predict(endpointName, instances, parameters);
    String textResponse = predictResponse.getPredictions(0).getStringValue();
    System.out.println(textResponse);
    return textResponse;
  }

  private static Value mapToValue(Map<String, Object> map) throws InvalidProtocolBufferException {
    Gson gson = new Gson();
    String json = gson.toJson(map);
    Value.Builder builder = Value.newBuilder();
    JsonFormat.parser().merge(json, builder);
    return builder.build();
  }
}

Go

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Go 설정 안내를 따르세요. 자세한 내용은 Vertex AI Go API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	"cloud.google.com/go/aiplatform/apiv1/aiplatformpb"

	"google.golang.org/protobuf/types/known/structpb"
)

// predictGPU demonstrates how to run interference on a Gemma2 model deployed to a Vertex AI endpoint with GPU accelerators.
func predictGPU(w io.Writer, client PredictionsClient, projectID, location, endpointID string) error {
	ctx := context.Background()

	// Note: client can be initialized in the following way:
	// apiEndpoint := fmt.Sprintf("%s-aiplatform.googleapis.com:443", location)
	// client, err := aiplatform.NewPredictionClient(ctx, option.WithEndpoint(apiEndpoint))
	// if err != nil {
	// 	return fmt.Errorf("unable to create prediction client: %v", err)
	// }
	// defer client.Close()

	gemma2Endpoint := fmt.Sprintf("projects/%s/locations/%s/endpoints/%s", projectID, location, endpointID)
	prompt := "Why is the sky blue?"
	parameters := map[string]interface{}{
		"temperature":     0.9,
		"maxOutputTokens": 1024,
		"topP":            1.0,
		"topK":            1,
	}

	// Encapsulate the prompt in a correct format for TPUs.
	// Pay attention that prompt should be set in "inputs" field.
	// Example format: [{'inputs': 'Why is the sky blue?', 'parameters': {'temperature': 0.9}}]
	promptValue, err := structpb.NewValue(map[string]interface{}{
		"inputs":     prompt,
		"parameters": parameters,
	})
	if err != nil {
		fmt.Fprintf(w, "unable to convert prompt to Value: %v", err)
		return err
	}

	req := &aiplatformpb.PredictRequest{
		Endpoint:  gemma2Endpoint,
		Instances: []*structpb.Value{promptValue},
	}

	resp, err := client.Predict(ctx, req)
	if err != nil {
		return err
	}

	prediction := resp.GetPredictions()
	value := prediction[0].GetStringValue()
	fmt.Fprintf(w, "%v", value)

	return nil
}

삭제

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

프로젝트 삭제

  1. In the Google Cloud console, go to the Manage resources page.

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then click Delete.
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

개별 리소스 삭제

프로젝트를 유지하려면 이 튜토리얼에서 사용된 리소스를 삭제합니다.

  • 모델 배포 취소 및 엔드포인트 삭제
  • Model Registry에서 모델 삭제

모델 배포 취소 및 엔드포인트 삭제

다음 방법 중 하나를 사용하여 모델을 배포 해제하고 엔드포인트를 삭제합니다.

콘솔

  1. Google Cloud 콘솔에서 온라인 예측을 클릭한 다음 엔드포인트를 클릭합니다.

    엔드포인트 페이지로 이동

  2. 리전 드롭다운 목록에서 엔드포인트를 배포한 리전을 선택합니다.

  3. 엔드포인트 이름을 클릭하여 세부정보 페이지를 엽니다. 예를 들면 gemma2-2b-it-mg-one-click-deploy입니다.

  4. Gemma 2 (Version 1) 모델 행에서 작업을 클릭한 다음 엔드포인트에서 모델 배포 취소를 클릭합니다.

  5. 엔드포인트에서 모델 배포 취소 대화상자에서 배포 취소를 클릭합니다.

  6. 뒤로 버튼을 클릭하여 엔드포인트 페이지로 돌아갑니다.

    엔드포인트 페이지로 이동

  7. gemma2-2b-it-mg-one-click-deploy 행 끝에서 작업을 클릭한 다음 엔드포인트 삭제를 선택합니다.

  8. 확인 메시지에서 확인을 클릭합니다.

gcloud

Google Cloud CLI를 사용하여 모델을 배포 해제하고 엔드포인트를 삭제하려면 다음 단계를 따르세요.

이 명령어에서 다음을 바꿉니다.

  • PROJECT_ID를 프로젝트 이름으로 바꿉니다.
  • LOCATION_ID을 모델과 엔드포인트를 배포한 리전으로 바꿉니다.
  • ENDPOINT_ID을 엔드포인트 ID로 바꿉니다.
  • DEPLOYED_MODEL_NAME: 모델의 표시 이름
  • DEPLOYED_MODEL_ID를 모델 ID로 바꿉니다.
  1. gcloud ai endpoints list 명령어를 실행하여 엔드포인트 ID를 가져옵니다. 이 명령어는 프로젝트의 모든 엔드포인트의 엔드포인트 ID를 나열합니다. 이 튜토리얼에서 사용된 엔드포인트의 ID를 기록해 둡니다.

    gcloud ai endpoints list \
        --project=PROJECT_ID \
        --region=LOCATION_ID
    

    출력은 다음과 같습니다. 출력에서 ID는 ENDPOINT_ID입니다.

    Using endpoint [https://us-central1-aiplatform.googleapis.com/]
    ENDPOINT_ID: 1234567891234567891
    DISPLAY_NAME: gemma2-2b-it-mg-one-click-deploy
    
  2. gcloud ai models describe 명령어를 실행하여 모델 ID를 가져옵니다. 이 튜토리얼에서 배포한 모델의 ID를 기록해 둡니다.

    gcloud ai models describe DEPLOYED_MODEL_NAME \
        --project=PROJECT_ID \
        --region=LOCATION_ID
    

    축약된 출력은 다음과 같습니다. 출력에서 ID는 deployedModelId입니다.

    Using endpoint [https://us-central1-aiplatform.googleapis.com/]
    artifactUri: [URI removed]
    baseModelSource:
      modelGardenSource:
        publicModelName: publishers/google/models/gemma2
    ...
    deployedModels:
    - deployedModelId: '1234567891234567891'
      endpoint: projects/12345678912/locations/us-central1/endpoints/12345678912345
    displayName: gemma2-2b-it-12345678912345
    etag: [ETag removed]
    modelSourceInfo:
      sourceType: MODEL_GARDEN
    name: projects/123456789123/locations/us-central1/models/gemma2-2b-it-12345678912345
    ...
    
  3. 엔드포인트에서 모델 배포를 취소합니다. 이전 명령어의 엔드포인트 ID와 모델 ID가 필요합니다.

    gcloud ai endpoints undeploy-model ENDPOINT_ID \
        --project=PROJECT_ID \
        --region=LOCATION_ID \
        --deployed-model-id=DEPLOYED_MODEL_ID
    

    이 명령어는 출력을 생성하지 않습니다.

  4. gcloud ai endpoints delete 명령어를 실행하여 엔드포인트를 삭제합니다.

    gcloud ai endpoints delete ENDPOINT_ID \
        --project=PROJECT_ID \
        --region=LOCATION_ID
    

    메시지가 표시되면 y를 입력하여 확인합니다. 이 명령어는 출력을 생성하지 않습니다.

모델 삭제

콘솔

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 Model Registry 페이지로 이동합니다.

    Model Registry 페이지로 이동

  2. 리전 드롭다운 목록에서 모델을 배포한 리전을 선택합니다.

  3. gemma2-2b-it-1234567891234 행 끝에서 작업을 클릭합니다.

  4. 모델 삭제를 선택합니다.

    모델을 삭제하면 모든 관련 모델 버전과 평가가 Google Cloud 프로젝트에서 삭제됩니다.

  5. 확인 메시지에서 삭제를 클릭합니다.

gcloud

Google Cloud CLI를 사용하여 모델을 삭제하려면 gcloud ai models delete 명령어에 모델의 표시 이름과 지역을 제공합니다.

gcloud ai models delete DEPLOYED_MODEL_NAME \
    --project=PROJECT_ID \
    --region=LOCATION_ID

DEPLOYED_MODEL_NAME을 모델의 표시 이름으로 바꿉니다. PROJECT_ID을 프로젝트 이름으로 바꿉니다. LOCATION_ID을 모델을 배포한 리전으로 바꿉니다.

다음 단계