无法将经过训练的模型部署到现有的AKS计算目标

杰森

我有一个在Azure机器学习服务上的机器学习计算上训练过的模型。注册的模型已经存在于我的工作空间中,我想将其部署到我先前在我的工作空间中预先配置的AKS实例。我能够成功配置和注册容器映像:

# retrieve cloud representations of the models
rf = Model(workspace=ws, name='pumps_rf')
le = Model(workspace=ws, name='pumps_le')
ohc = Model(workspace=ws, name='pumps_ohc')
print(rf); print(le); print(ohc)

<azureml.core.model.Model object at 0x7f66ab3b1f98>
<azureml.core.model.Model object at 0x7f66ab7e49b0>
<azureml.core.model.Model object at 0x7f66ab85e710>

package_list = [
  'category-encoders==1.3.0',
  'numpy==1.15.0',
  'pandas==0.24.1',
  'scikit-learn==0.20.2']

# Conda environment configuration
myenv = CondaDependencies.create(pip_packages=package_list)
conda_yml = 'file:'+os.getcwd()+'/myenv.yml'

with open(conda_yml,"w") as f:
    f.write(myenv.serialize_to_string())

配置和注册映像的工作原理:

# Image configuration
image_config = ContainerImage.image_configuration(execution_script='score.py', 
                                                  runtime='python', 
                                                  conda_file='myenv.yml',
                                                  description='Pumps Random Forest model')


# Register the image from the image configuration
# to Azure Container Registry
image = ContainerImage.create(name = Config.IMAGE_NAME, 
                              models = [rf, le, ohc],
                              image_config = image_config,
                              workspace = ws)

Creating image
Running....................
SucceededImage creation operation finished for image pumpsrfimage:2, operation "Succeeded"

附加到现有集群也可以:

# Attach the cluster to your workgroup
attach_config = AksCompute.attach_configuration(resource_group = Config.RESOURCE_GROUP,
                                                cluster_name = Config.DEPLOY_COMPUTE)
aks_target = ComputeTarget.attach(workspace=ws, 
                                  name=Config.DEPLOY_COMPUTE, 
                                  attach_configuration=attach_config)

# Wait for the operation to complete
aks_target.wait_for_completion(True)
SucceededProvisioning operation finished, operation "Succeeded"

但是,当我尝试将映像部署到现有群集时,它会失败,并显示WebserviceException

# Set configuration and service name
aks_config = AksWebservice.deploy_configuration()

# Deploy from image
service = Webservice.deploy_from_image(workspace = ws,
                                       name = 'pumps-aks-service-1' ,
                                       image = image,
                                       deployment_config = aks_config,
                                       deployment_target = aks_target)
# Wait for the deployment to complete
service.wait_for_deployment(show_output = True)
print(service.state)

WebserviceException: Unable to create service with image pumpsrfimage:1 in non "Succeeded" creation state.
---------------------------------------------------------------------------
WebserviceException                       Traceback (most recent call last)
<command-201219424688503> in <module>()
      7                                        image = image,
      8                                        deployment_config = aks_config,
----> 9                                        deployment_target = aks_target)
     10 # Wait for the deployment to complete
     11 service.wait_for_deployment(show_output = True)

/databricks/python/lib/python3.5/site-packages/azureml/core/webservice/webservice.py in deploy_from_image(workspace, name, image, deployment_config, deployment_target)
    284                         return child._deploy(workspace, name, image, deployment_config, deployment_target)
    285 
--> 286         return deployment_config._webservice_type._deploy(workspace, name, image, deployment_config, deployment_target)
    287 
    288     @staticmethod

/databricks/python/lib/python3.5/site-packages/azureml/core/webservice/aks.py in _deploy(workspace, name, image, deployment_config, deployment_target)

关于如何解决此问题的任何想法?我正在Databricks笔记本中编写代码。另外,我能够使用Azure Portal创建和部署群集没有问题,因此这似乎与我的代码/ Python SDK或Databricks与AMLS的工作方式有关。

更新:我能够使用Azure Portal将映像部署到AKS,并且Web服务按预期工作。这意味着问题出在Databricks,Azureml Python SDK和机器学习服务之间。

更新2:我正在与Microsoft一起解决此问题。一旦有解决方案,我们将向您报告。

杰森

在我的初始代码中,创建图像时,我没有使用:

image.wait_for_creation(show_output=True)

结果,我打电话来CreateImageDeployImage在创建错误图像之前。简直不敢这么简单..

更新的图像创建片段:

# Register the image from the image configuration
# to Azure Container Registry
image = ContainerImage.create(name = Config.IMAGE_NAME, 
                              models = [rf, le, ohc],
                              image_config = image_config,
                              workspace = ws)

image.wait_for_creation(show_output=True)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法使用自定义的预测例程将经过训练的模型部署到Google Cloud Ai平台:模型所需的内存超出了允许的范围

将定制的经过训练的NER模型与Stanford CoreNLP中的现有默认模型集成

如何使用计算目标获取现有的AKS

将经过训练的Tensorflow模型转换为protobuf

将经过训练的模型存储在R包中

Tensorflow(tfjs)-保存经过训练的模型

如何加载经过训练的 RandomForestClassificationModel 模型?

使用经过训练的模型进行预测

我们如何在移动设备上部署经过训练的张量流模型?

无法将bna部署到现有的Hyperledger Fabric安装中

将Keras模型导出为TF估计器:找不到经过训练的模型

加载经过训练的Keras模型并继续训练

无法使用经过训练的NSGA-Net PyTorch模型生成对抗性示例

如何将经过训练的 Caffe 模型用于当前输入图像?

如何将经过训练的机器学习模型从 AI Patform 导入 python 中的云函数

保存的 sklearn 模型的预测与经过训练的模型不同

在C ++中运行经过训练的张量流模型

在PyTorch中保存经过训练的模型的最佳方法?

Tensorflow:提取经过训练的模型的特征

预测经过训练的 DNN 模型的类别时出错

如何在 Django 中加载经过训练的模型

如何加载经过训练的模型以推断预测数据

在AWS SageMaker上重新托管经过训练的模型

如何使用经过训练的Tensorflow模型进行预测

Tensorflow:如何保存经过训练的模型的差异

如何将新数字手写训练成现有的 keras 模型?

将本地捆绑部署到现有计算机

在哪里可以找到经过训练的模型(如googleNet的输出)到真实类标签之间的标签图?

我无法使用load.models()加载经过训练的h5模型,如何解决此错误?