gpt4 book ai didi

python - 在python中获取AzureML环境 `source`字段

转载 作者:行者123 更新时间:2023-12-03 05:13:22 24 4
gpt4 key购买 nike

我正在尝试使用 python SDK(版本 1 或 2)获取 AzureML 环境的 source 字段。
看起来版本 1 和版本 2 都不支持它,尽管 Web UI 有它。

有人有想法吗?

enter image description here

最佳答案

我的 Azure ML 工作区环境:-

enter image description here

源是 Azure ML 环境的一部分。您可以使用以下代码按其特定名称列出所有环境或将所有列表一起列出,并且源将在输出中附加环境名称,如下所示:-

确保将您的客户端 ID 和客户端 key 替换为有权访问 azure ml 工作区的服务主体。

列出整个列表:-

代码:-

from azure.identity import  ClientSecretCredential

from azure.ai.ml import MLClient



subscription_id = "<subscription-id>"

resource_group = "siliconrg"

workspace_name = "siliconmlws"

tenant_id = "<tenant-id>"

client_id = "<client-id>"

client_secret = "<client-secret>"



credentials = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)



ml_client = MLClient(credentials, subscription_id, resource_group, workspace_name)

envs = ml_client.environments.list()

for env in envs:

print(env.name)

输出:-

enter image description here

通过添加名称来列出特定环境,如下代码所示:-

代码:-

from azure.identity import  ClientSecretCredential

from azure.ai.ml import MLClient



subscription_id = "<subscription-id>"

resource_group = "siliconrg"

workspace_name = "siliconmlws"

tenant_id = "<tenant-id>"

client_id = "<client-id>"

client_secret = "<client-secret>"



credentials = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)



ml_client = MLClient(credentials, subscription_id, resource_group, workspace_name)

envs = ml_client.environments.list(name="AzureML-ACPT-pytorch-1.13-py38-cuda11.7-gpu")

for env in envs:

print(env.name)

输出:-

enter image description here

引用:-

Manage Azure Machine Learning environments with the CLI & SDK (v2) - Azure Machine Learning | Microsoft Learn

关于python - 在python中获取AzureML环境 `source`字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75812640/

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