az ml model
Note
This reference is part of the ml extension for the Azure CLI (version 2.15.0 or higher). 该扩展将在首次运行 az ml model 命令时自动安装。 Learn more about extensions.
管理 Azure ML 模型。
Azure ML 模型由表示机器学习模型和任何相应元数据的二进制文件组成。 可以在终结点部署中使用这些模型进行实时和批处理推理。
命令
名称 | 说明 | 类型 | Status |
---|---|---|---|
az ml model archive |
存档模型。 |
Extension | GA |
az ml model create |
创建模型。 |
Extension | GA |
az ml model download |
下载所有与模型相关的文件。 |
Extension | GA |
az ml model list |
列出工作区/注册表中的模型。 如果使用注册表,请替换为 |
Extension | GA |
az ml model package |
将模型打包到环境中。 |
Extension | Preview |
az ml model restore |
还原存档的模型。 |
Extension | GA |
az ml model share |
从工作区共享到注册表的特定模型。 |
Extension | GA |
az ml model show |
显示工作区/注册表中模型的详细信息。 如果使用注册表,请替换为 |
Extension | GA |
az ml model update |
更新工作区/注册表中的模型。 |
Extension | GA |
az ml model archive
存档模型。
默认情况下,将模型存档会使其从列表查询 (az ml model list
) 中隐藏。 你仍然可以继续在工作流中引用和使用已存档的模型。 可以存档模型容器或特定模型版本。 存档模型容器将存档该给定名称下模型的所有版本。 可以使用 .. 还原存档的模型 az ml model restore
。 如果存档整个模型容器,则无法还原模型的各个版本 - 需要还原模型容器。
az ml model archive --name
[--label]
[--registry-name]
[--resource-group]
[--version]
[--workspace-name]
示例
存档模型容器(存档该模型的所有版本)
az ml model archive --name my-model --resource-group my-resource-group --workspace-name my-workspace
存档特定模型版本
az ml model archive --name my-model --version 1 --resource-group my-resource-group --workspace-name my-workspace
必需参数
模型的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
模型的标签。
如果提供,该命令将面向注册表而不是工作区。 因此,不需要资源组和工作区。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
模型的版本。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az ml model create
创建模型。
可以从本地文件、本地目录、数据存储或作业输出创建模型。 创建的模型将在指定名称和版本下的工作区/注册表中跟踪。 如果使用注册表,请替换为--workspace-name my-workspace
--registry-name <registry-name>
该选项。
az ml model create [--datastore]
[--description]
[--file]
[--name]
[--no-wait]
[--path]
[--registry-name]
[--resource-group]
[--set]
[--stage]
[--tags]
[--type]
[--version]
[--workspace-name]
示例
从 YAML 规范文件创建模型
az ml model create --file model.yml --resource-group my-resource-group --workspace-name my-workspace
使用命令选项从本地文件夹创建模型
az ml model create --name my-model --version 1 --path ./my-model --resource-group my-resource-group --workspace-name my-workspace
使用 mlflow 运行 URI 格式“runs:/<run-id>/<path-to-model-relative-to-the-root-of-the-artifact-location>”和命令选项创建模型
az ml model create --name my-model --version 1 --path runs:/c42d2507-4953-4a7c-a4c1-2b5bfe0ac64e/model/ --type mlflow_model --resource-group my-resource-group --workspace-name my-workspace
使用 azureml 作业 URI 格式“azureml://jobs/<job-name>/outputs/<named-output>/paths/<path-to-model-relative-to-the-named-output-location>” 和命令选项从命名作业输出创建模型。 默认命名输出是项目
az ml model create --name my-model --version 1 --path azureml://jobs/c42d2507-4953-4a7c-a4c1-2b5bfe0ac64e/outputs/artifacts/paths/model/ --resource-group my-resource-group --workspace-name my-workspace
使用命令选项从数据存储“azureml://datastores/<datastore-name>/paths/<path-to-model-relative-to-the-root-of-the-datastore-location>”创建模型
az ml model create --name my-model --version 1 --path azureml://datastores/myblobstore/paths/models/cifar10/cifar.pt --resource-group my-resource-group --workspace-name my-workspace
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
要将本地项目上传到的数据存储。
模型的说明。
包含 Azure ML 模型规范的 YAML 文件的本地路径。 可以在以下位置找到模型的 YAML 参考文档:https://aka.ms/ml-cli-v2-model-yaml-reference。
模型的名称。
不等待长时间运行的操作完成。
属性 | 值 |
---|---|
默认值: | False |
模型文件的路径。 这可以是本地位置,也可以是远程位置。 如果指定,还必须提供 --name/-n 和 --version/-v。
如果提供,该命令将面向注册表而不是工作区。 因此,不需要资源组和工作区。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=value。
模型的阶段。
对象的标记的空间分隔键值对。
模型的类型,允许的值是custom_model、mlflow_model和triton_model。 默认类型为custom_model。
模型的版本。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az ml model download
下载所有与模型相关的文件。
文件将下载到以模型名称命名的文件夹。 如果使用注册表,请替换为--workspace-name my-workspace
--registry-name <registry-name>
该选项。
az ml model download --name
--version
[--download-path]
[--registry-name]
[--resource-group]
[--workspace-name]
示例
下载具有指定名称和版本的模型
az ml model download --name my-model --version 1 --resource-group my-resource-group --workspace-name my-workspace
将具有指定名称和版本的模型下载到指定的本地路径中
az ml model download --name my-model --version 1 --download-path local_path --resource-group my-resource-group --workspace-name my-workspace
必需参数
模型的名称。
模型的版本。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
下载模型文件的路径默认为当前工作目录。
如果提供,该命令将面向注册表而不是工作区。 因此,不需要资源组和工作区。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az ml model list
列出工作区/注册表中的模型。 如果使用注册表,请替换为--workspace-name my-workspace
--registry-name <registry-name>
该选项。
az ml model list [--archived-only]
[--include-archived]
[--max-results]
[--name]
[--registry-name]
[--resource-group]
[--stage]
[--workspace-name]
示例
列出工作区中的所有模型
az ml model list --resource-group my-resource-group --workspace-name my-workspace
列出工作区中指定名称的所有模型版本
az ml model list --name my-model --resource-group my-resource-group --workspace-name my-workspace
使用 --query 参数对命令结果执行 JMESPath 查询,列出工作区中的所有模型。
az ml model list --query "[].{Name:name}" --output table --resource-group my-resource-group --workspace-name my-workspace
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
仅列出存档的模型。
属性 | 值 |
---|---|
默认值: | False |
列出存档的模型和活动模型。
属性 | 值 |
---|---|
默认值: | False |
要返回的最大结果数。
模型的名称。 如果提供,将返回此名称下的所有模型版本。
如果提供,该命令将面向注册表而不是工作区。 因此,不需要资源组和工作区。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
模型的阶段。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az ml model package
此命令处于预览阶段,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus
将模型打包到环境中。
打包模型时,将创建具有所有依赖项的环境。
az ml model package --file
--name
--version
[--registry-name]
[--resource-group]
[--workspace-name]
示例
使用指定名称和版本打包模型
az ml model package --name my-model --version my-version --resource-group my-resource-group --workspace-name my-workspace --file my-package.yml
必需参数
包含模型包定义的 YAML 文件的本地路径。
模型的名称。
模型的版本。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
如果提供,该命令将面向注册表而不是工作区。 因此,不需要资源组和工作区。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az ml model restore
还原存档的模型。
还原存档的模型后,将不再隐藏列表查询(az ml model list
)。 如果已存档整个模型容器,则可以还原该存档的容器。 这将还原该给定名称下模型的所有版本。 如果已存档整个模型容器,则不能仅还原特定模型版本 - 需要还原整个容器。 如果仅存档了单个模型版本,则可以还原该特定版本。
az ml model restore --name
[--label]
[--registry-name]
[--resource-group]
[--version]
[--workspace-name]
示例
还原存档的模型容器(还原该模型的所有版本)
az ml model restore --name my-model --resource-group my-resource-group --workspace-name my-workspace
还原特定的存档模型版本
az ml model restore --name my-model --version 1 --resource-group my-resource-group --workspace-name my-workspace
必需参数
模型的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
模型的标签。
如果提供,该命令将面向注册表而不是工作区。 因此,不需要资源组和工作区。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
模型的版本。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az ml model share
从工作区共享到注册表的特定模型。
将现有模型从工作区复制到注册表,以便重复使用跨工作区。
az ml model share --name
--registry-name
--share-with-name
--share-with-version
--version
[--resource-group]
[--workspace-name]
示例
将现有环境从工作区共享到注册表
az ml model share --name my-model --version my-version --resource-group my-resource-group --workspace-name my-workspace --share-with-name new-name-in-registry --share-with-version new-version-in-registry --registry-name my-registry
必需参数
模型的名称。
Destination registry.
要创建的模型的名称。
要创建的模型的版本。
模型的版本。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az ml model show
显示工作区/注册表中模型的详细信息。 如果使用注册表,请替换为--workspace-name my-workspace
--registry-name <registry-name>
该选项。
az ml model show --name
[--label]
[--registry-name]
[--resource-group]
[--version]
[--workspace-name]
示例
显示具有指定名称和版本的模型的详细信息
az ml model show --name my-model --version 1 --resource-group my-resource-group --workspace-name my-workspace
必需参数
模型的名称。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
模型的标签。
如果提供,该命令将面向注册表而不是工作区。 因此,不需要资源组和工作区。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
模型的版本。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az ml model update
更新工作区/注册表中的模型。
可以更新“description”和“tags”属性。 如果使用注册表,请替换为--workspace-name my-workspace
--registry-name <registry-name>
该选项。
az ml model update --name
--resource-group
[--add]
[--force-string]
[--label]
[--registry-name]
[--remove]
[--set]
[--stage]
[--version]
[--workspace-name]
示例
更新模型风格
az ml model update --name my-model --version 1 --set flavors.python_function.python_version=3.8 --resource-group my-resource-group --workspace-name my-workspace
必需参数
模型的名称。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
通过指定路径和键值对将对象添加到对象列表。 示例:--add property.listProperty <key=value, string or JSON string>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | False |
模型的标签。
如果提供,该命令将面向注册表而不是工作区。 因此,不需要资源组和工作区。
从列表中删除属性或元素。 示例: --remove property.list <indexToRemove>
OR --remove propertyToRemove
.
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=<value>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
模型的阶段。
模型的版本。
Azure ML 工作区的名称。 可以使用 配置默认工作区 az configure --defaults workspace=<name>
。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |