Vertex AI 모델 레지스트리에서 모델 삭제

Vertex AI 모델 레지스트리에서 더 이상 필요하지 않은 모델을 삭제하는 방법을 알아봅니다.

Vertex AI 모델 레지스트리에서 BigQuery ML을 삭제하려면 먼저 BigQuery ML에서 삭제해야 합니다. 자세한 내용은 BigQuery ML 및 Vertex AI Model Registry를 참조하세요.

현재 엔드포인트에 배포된 모델을 삭제하려면 먼저 배포를 취소해야 합니다. 그렇지 않으면 모델을 삭제할 수 없습니다.

모델 삭제

콘솔

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

    Model Registry 페이지로 이동

  2. 삭제할 모델에서 추가 작업을 선택합니다.

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

  4. 확인 화면에서 삭제를 클릭합니다.

API

Python용 Vertex AI SDK를 사용하여 모델을 삭제합니다.

Python


from google.cloud import aiplatform

def delete_model_sample(model_id: str, project: str, location: str):
    """
    Delete a Model resource.
    Args:
        model_id: The ID of the model to delete. Parent resource name of the model is also accepted.
        project: The project.
        location: The region name.
    Returns
        None.
    """
    # Initialize the client.
    aiplatform.init(project=project, location=location)

    # Get the model with the ID 'model_id'. The parent_name of Model resource can be also
    # 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
    model = aiplatform.Model(model_name=model_id)

    # Delete the model.
    model.delete()

모델 버전 삭제

콘솔

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

    Model Registry 페이지로 이동

  2. 모델을 펼쳐 모델 버전을 봅니다. 삭제할 버전을 선택합니다.

  3. 모델 버전 메뉴 에서 작업 더보기를 선택합니다.

  4. 버전 삭제를 선택합니다. 버전을 삭제하면 연결된 모든 모델 평가가 삭제됩니다.

API

Python


from google.cloud import aiplatform

def delete_model_version_sample(
    model_id: str, version_id: str, project: str, location: str
):
    """
    Delete a Model version.
    Args:
        model_id: The ID of the model to delete. Parent resource name of the model is also accepted.
        version_id: The version ID or version alias of the model to delete.
        project: The project ID.
        location: The region name.
    Returns
        None.
    """
    # Initialize the client.
    aiplatform.init(project=project, location=location)

    # Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
    # 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
    model_registry = aiplatform.models.ModelRegistry(model=model_id)

    # Delete the model version with the version 'version'.
    model_registry.delete_version(version=version_id)

기본 별칭이 있는 모델 버전 삭제

콘솔

  1. 모델 레지스트리에서 모델 이름을 선택하여 모델 버전을 봅니다.
  2. 원하는 버전을 선택하고 작업 버튼 에서 삭제를 클릭합니다. 기본 별칭 버전을 삭제하려고 시도하기 때문에 경고가 표시됩니다. 먼저 다른 버전을 기본 버전으로 설정하세요.
  3. 드롭다운에서 모델의 기본값으로 사용할 버전을 선택합니다.
  4. 확인 화면에서 설정 및 삭제를 클릭합니다.

API

Python


from typing import List

from google.cloud import aiplatform

def delete_aliases_model_version_sample(
    model_id: str,
    version_aliases: List[str],
    version_id: str,
    project: str,
    location: str,
):
    """
    Delete aliases to a model version.
    Args:
        model_id: The ID of the model.
        version_aliases: The version aliases to assign.
        version_id: The version ID of the model to assign the aliases to.
        project: The project ID.
        location: The region name.
    Returns
        None.
    """
    # Initialize the client.
    aiplatform.init(project=project, location=location)

    # Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
    # 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
    model_registry = aiplatform.models.ModelRegistry(model=model_id)

    # Remove the version aliases to the model version with the version 'version'.
    model_registry.remove_version_aliases(
        target_aliases=version_aliases, version=version_id
    )