如何使用本地包创建 azure 机器学习评分图像
how create azure machine learning scoring image using local package
我将 pkl 包保存在我的 azure devops 存储库中
使用下面的代码在工作区中搜索包。
如何提供存储库中保存的包
ws = Workspace.get(
name=workspace_name,
subscription_id=subscription_id,
resource_group=resource_group,
auth=cli_auth)
image_config = ContainerImage.image_configuration(
execution_script="score.py",
runtime="python-slim",
conda_file="conda.yml",
description="Image with ridge regression model",
tags={"area": "ml", "type": "dev"},
)
image = Image.create(
name=image_name, models=[model], image_config=image_config, workspace=ws
)
image.wait_for_creation(show_output=True)
if image.creation_state != "Succeeded":
raise Exception("Image creation status: {image.creation_state}")
print(
"{}(v.{} [{}]) stored at {} with build log {}".format(
image.name,
image.version,
image.creation_state,
image.image_location,
image.image_build_log_uri,
)
)
# Writing the image details to /aml_config/image.json
image_json = {}
image_json["image_name"] = image.name
image_json["image_version"] = image.version
image_json["image_location"] = image.image_location
with open("aml_config/image.json", "w") as outfile:
json.dump(image_json, outfile)
我试图提供模型的路径,但它失败说找不到包
型号 = $(System.DefaultWorkingDirectory)/package_model.pkl
注册型号:
通过调用 Model.register().
将文件或文件夹注册为模型
除了模型文件本身的内容之外,您注册的模型还将存储模型元数据——模型描述、标签和框架信息——这在您的工作区中管理和部署模型时非常有用。例如,使用标签,您可以对模型进行分类并在工作区中列出模型时应用过滤器。
model = Model.register(workspace=ws,
model_name='', # Name of the registered model in your workspace.
model_path='', # Local file to upload and register as a model.
model_framework=Model.Framework.SCIKITLEARN, # Framework used to create the model.
model_framework_version=sklearn.__version__, # Version of scikit-learn used to create the model.
sample_input_dataset=input_dataset,
sample_output_dataset=output_dataset,
resource_configuration=ResourceConfiguration(cpu=1, memory_in_gb=0.5),
description='Ridge regression model to predict diabetes progression.',
tags={'area': 'diabetes', 'type': 'regression'})
print('Name:', model.name)
print('Version:', model.version)
将机器学习模型部署到 Azure:https://docs.microsoft.com/en-us/azure/machine-learning/how-to-deploy-and-where?tabs=python
远程模型部署疑难解答请遵循document。
我将 pkl 包保存在我的 azure devops 存储库中
使用下面的代码在工作区中搜索包。 如何提供存储库中保存的包
ws = Workspace.get(
name=workspace_name,
subscription_id=subscription_id,
resource_group=resource_group,
auth=cli_auth)
image_config = ContainerImage.image_configuration(
execution_script="score.py",
runtime="python-slim",
conda_file="conda.yml",
description="Image with ridge regression model",
tags={"area": "ml", "type": "dev"},
)
image = Image.create(
name=image_name, models=[model], image_config=image_config, workspace=ws
)
image.wait_for_creation(show_output=True)
if image.creation_state != "Succeeded":
raise Exception("Image creation status: {image.creation_state}")
print(
"{}(v.{} [{}]) stored at {} with build log {}".format(
image.name,
image.version,
image.creation_state,
image.image_location,
image.image_build_log_uri,
)
)
# Writing the image details to /aml_config/image.json
image_json = {}
image_json["image_name"] = image.name
image_json["image_version"] = image.version
image_json["image_location"] = image.image_location
with open("aml_config/image.json", "w") as outfile:
json.dump(image_json, outfile)
我试图提供模型的路径,但它失败说找不到包
型号 = $(System.DefaultWorkingDirectory)/package_model.pkl
注册型号: 通过调用 Model.register().
将文件或文件夹注册为模型除了模型文件本身的内容之外,您注册的模型还将存储模型元数据——模型描述、标签和框架信息——这在您的工作区中管理和部署模型时非常有用。例如,使用标签,您可以对模型进行分类并在工作区中列出模型时应用过滤器。
model = Model.register(workspace=ws,
model_name='', # Name of the registered model in your workspace.
model_path='', # Local file to upload and register as a model.
model_framework=Model.Framework.SCIKITLEARN, # Framework used to create the model.
model_framework_version=sklearn.__version__, # Version of scikit-learn used to create the model.
sample_input_dataset=input_dataset,
sample_output_dataset=output_dataset,
resource_configuration=ResourceConfiguration(cpu=1, memory_in_gb=0.5),
description='Ridge regression model to predict diabetes progression.',
tags={'area': 'diabetes', 'type': 'regression'})
print('Name:', model.name)
print('Version:', model.version)
将机器学习模型部署到 Azure:https://docs.microsoft.com/en-us/azure/machine-learning/how-to-deploy-and-where?tabs=python
远程模型部署疑难解答请遵循document。