gpt4 book ai didi

python - 使用 python SDK v2 删除 AzureML 模型

转载 作者:行者123 更新时间:2023-12-03 06:23:41 40 4
gpt4 key购买 nike

我正在尝试使用 python SDK v2 删除 AzureML 模型,
但我找不到这样的功能。
这有点令人惊讶,因为 Web UI 中有这样的功能。

正在查看两者 azure.ai.ml.entities.Modelazure.ai.ml.operations.ModelOperations (定义所有 ml_client.models.<operation> 操作的类) - 找不到对它们下的删除操作的支持。

编辑1:
v2 CLI 也不支持删除(归档不是删除) enter image description here

编辑2:
作为部分解决方案,这可以使用 SDK v1 来实现:

from azureml.core import Workspace, Model
workspace = ...
model = Model(workspace=workspace, name=name, version=version)
model.delete()

最佳答案

using Azure cli and python sdk I Deleted Azure ML model using python SDK 1.49.0

  • 使用 Azure cli 我得到了相同的命令

enter image description here

  • 添加 az 扩展后我能够找到删除命令
  az extension add -n azure-cli-ml

enter image description here

   az ml model delete --model-id <model_id> --workspace-name <workspace_name> --resource-group <resource_group> --subscription <subscription_id>

enter image description here

  • 使用Python SDK

from azureml.core import Workspace, Model

# Replace with your AzureML workspace details
subscription_id = "your-subscription-id"
resource_group = "your-resource-group"
workspace_name = "your-workspace-name"

# Replace with your model name and version
model_name = "your-model-name"
model_version = 2

workspace = Workspace(subscription_id, resource_group, workspace_name)

# Get the model using the Model class
model = Model(workspace=workspace, name=model_name, version=model_version)

model = Model(workspace, name=model_name)

model_id = model.id



print("Model ID:", model_id)

# Delete the model
model.delete()

print("Model deleted successfully.")

enter image description here

enter image description here

关于python - 使用 python SDK v2 删除 AzureML 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75712901/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com