Modell aus Vertex AI Model Registry löschen

Erfahren Sie, wie Sie ein Modell, das Sie nicht mehr benötigen, aus der Vertex AI Model Registry löschen.

Wenn Sie ein BigQuery ML-Modell aus der Vertex AI Model Registry löschen möchten, müssen Sie es zuerst aus BigQuery ML löschen. Weitere Informationen finden Sie unter BigQuery ML und Vertex AI Model Registry.

Wenn Sie ein Modell löschen möchten, das derzeit auf einem Endpunkt bereitgestellt wird, müssen Sie zuerst die Bereitstellung aufheben. Andernfalls können Sie das Modell nicht löschen.

Modell löschen

Console

  1. Rufen Sie in der Google Cloud Console im Bereich "Vertex AI" die Seite Model Registry auf.

    Zur Seite Model Registry

  2. Wählen Sie im Modell, das Sie löschen möchten, Weitere Aktionen aus.

  3. Wählen Sie Modell löschen aus. Wenn Sie das Modell löschen, werden alle zugehörigen Modellversionen und -bewertungen aus Ihrem Google Cloud-Projekt gelöscht.

  4. Klicken Sie im Bestätigungsbildschirm auf Löschen.

API

Löschen Sie ein Modell mit dem Vertex AI SDK für Python.

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()

Modellversion löschen

Console

  1. Rufen Sie in der Google Cloud Console im Bereich "Vertex AI" die Seite Model Registry auf.

    Zur Seite Model Registry

  2. Maximieren Sie das Modell, um die Modellversionen aufzurufen. Wählen Sie die Version aus, die Sie löschen möchten.

  3. Wählen Sie im Dreipunkt-Menü  der Modellversion die Option Weitere Aktionen aus.

  4. Wählen Sie Version löschen aus. Wenn Sie Ihre Version löschen, werden alle zugehörigen Modellbewertungen ebenfalls gelöscht.

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)

Modellversion mit dem Standardalias löschen

Console

  1. Wählen Sie in Model Registry den Modellnamen aus, um die Modellversionen aufzurufen.
  2. Wählen Sie die gewünschte Version aus, klicken Sie auf die Schaltfläche Aktionen und klicken Sie dann auf Löschen. Eine Warnung wird geöffnet, da Sie versuchen, die Standard-Aliasversion zu löschen. Legen Sie zuerst andere Version als Standard fest.
  3. Wählen Sie im Drop-down-Menü die Version aus, die Sie als Modell verwenden möchten.
  4. Klicken Sie auf dem Bestätigungsbildschirm auf Festlegen und löschen.

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
    )