首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >无法将经过训练的模型部署到现有AKS计算目标

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

Stack Overflow用户
提问于 2019-02-21 07:15:26
回答 3查看 885关注 0票数 2

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

代码语言:javascript
代码运行次数:0
运行
复制
# 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())

配置和注册镜像工作:

代码语言:javascript
代码运行次数:0
运行
复制
# 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"

附加到现有群集也可以:

代码语言:javascript
代码运行次数:0
运行
复制
# 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

代码语言:javascript
代码运行次数:0
运行
复制
# 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,was服务工作正常。这意味着问题存在于Databricks、Azureml Python SDK和Machine Learning Service之间。

更新2:我正在与微软合作来解决这个问题。一旦我们有了解决方案就会报告。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-03-08 04:22:05

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

代码语言:javascript
代码运行次数:0
运行
复制
image.wait_for_creation(show_output=True)

因此,我在创建映像之前调用了CreateImageDeployImage,但出现了错误。不敢相信有这么简单..。

更新的镜像创建片段:

代码语言:javascript
代码运行次数:0
运行
复制
# 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)
票数 2
EN

Stack Overflow用户

发布于 2019-02-21 23:56:25

根据个人经验,我会说你看到的错误消息可能表明图像中的脚本有一些错误。这样的错误不一定会阻止镜像的成功创建,但它可能会阻止镜像在服务中使用。但是,如果您已经能够成功地在其他服务中部署映像,那么您应该能够排除此选项。

您可以关注this guide,了解有关如何在本地调试Docker镜像的更多信息,以及查找日志和其他有用信息。

票数 1
EN

Stack Overflow用户

发布于 2019-03-04 21:54:29

同意Arvid的回答。你能成功地运行它吗?您也可以尝试将其部署到ACI,但如果问题出在score.py中,您也会遇到相同的问题,但它很快就会尝试。此外,如果您想调试部署,也会有点痛苦,但您可以公开本地docker部署上的TCP5678端口,并使用VSCode和PTVSD连接到该端口并逐步进行调试。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54796762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档