מחיקת מודל מ-Vertex AI Model Registry

איך מוחקים מודל שכבר לא צריך ממרשם המודלים של Vertex AI

אם רוצים למחוק מודל BigQuery ML ממרשם המודלים של Vertex AI, קודם צריך למחוק אותו מ-BigQuery ML. מידע נוסף זמין במאמר BigQuery ML ומרשם המודלים של Vertex AI.

אם רוצים למחוק מודל שפריסתו בוצעה לנקודת קצה, צריך לבטל קודם את הפריסה שלו. אחרת, לא תוכלו למחוק את המודל.

מחיקת מודל

המסוף

  1. נכנסים לדף מרשם המודלים בקטע Vertex AI במסוף Google Cloud .

    כניסה לדף מרשם המודלים

  2. בוחרים באפשרות פעולות נוספות בדגם שרוצים למחוק.

  3. בוחרים באפשרות מחיקת המודל. כשמוחקים את המודל, כל הגרסאות וההערכות שמשויכות אליו נמחקות מהפרויקט Google Cloud .

  4. לוחצים על מחיקה במסך האישור.

gcloud

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • MODEL_ID: מזהה המודל.
  • PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
  • LOCATION: האזור של הפרויקט. לדוגמה, us-central1. אם האזור בכתובת ה-URL של נקודת קצה ל-API סותר את המיקום בנתיב המשאב, המערכת מתעלמת מהמיקום בנתיב.

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או Cloud Shell

gcloud ai models delete MODEL_ID \
    --project=PROJECT_ID \
    --region=LOCATION

‏Windows (PowerShell)

gcloud ai models delete MODEL_ID `
    --project=PROJECT_ID `
    --region=LOCATION

Windows‏ (cmd.exe)

gcloud ai models delete MODEL_ID ^
    --project=PROJECT_ID ^
    --region=LOCATION

API

מחיקת מודל באמצעות Vertex AI SDK ל-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()

מחיקת גרסת מודל

המסוף

  1. נכנסים לדף מרשם המודלים בקטע Vertex AI במסוף Google Cloud .

    כניסה לדף מרשם המודלים

  2. מרחיבים את המודל כדי לראות את גרסאות המודל. בוחרים את הגרסה שרוצים למחוק.

  3. בתפריט פעולות נוספות של גרסת המודל, לוחצים על .

  4. בוחרים באפשרות מחיקת גרסה. כשמוחקים גרסה, כל הערכות המשויכות של המודל נמחקות.

gcloud

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • MODEL_VERSION_ID: המזהה של גרסת המודל שרוצים למחוק.
  • PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
  • LOCATION: האזור של הפרויקט. לדוגמה, us-central1. אם האזור בכתובת ה-URL של נקודת קצה ל-API סותר את המיקום בנתיב המשאב, המערכת מתעלמת מהמיקום בנתיב.

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או Cloud Shell

gcloud ai models delete-version MODEL_VERSION_ID \
    --project=PROJECT_ID \
    --region=LOCATION

‏Windows (PowerShell)

gcloud ai models delete-version MODEL_VERSION_ID `
    --project=PROJECT_ID `
    --region=LOCATION

Windows‏ (cmd.exe)

gcloud ai models delete-version MODEL_VERSION_ID ^
    --project=PROJECT_ID ^
    --region=LOCATION

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
    )