使用 Azure 机器学习服务部署模型时遇到的问题

问题描述 投票:0回答:1

我已经在我的本地机器上构建了一个分类模型,现在我正在使用 Azure 机器学习进行部署。

我已经在 AzureML 上注册了我的模型。

现在在部署或尝试公开 Web 服务时,我遇到了 docker 映像创建的问题。


wenv= CondaDependencies()
wenv.add_conda_package("scikit-learn")

with open("wenv.yml", "w") as f:
f.write(wenv.serialize_to_string())
with open("wenv.yml","r") as f:
print(f.read())




image_config =ContainerImage.image_configuration(execution_script="scorete.py",
runtime="python",
conda_file="wenv.yml")

#Expose Web Service

service_name = 'telecoinference'
service =Webservice.deploy_from_model(workspace= ws,
name= service_name,
deployment_config=aciconfig,
models=\[model\],
image_config=image_config)
service.wait_for_deployment(show_output=True)
print(service.state)

WebserviceException                       Traceback (most recent call last)
\<ipython-input-50-cbddf70eccff\> in \<module\>
7                                      deployment_config=aciconfig,
8                                      models=\[model\],
\----\> 9                                      image_config=image_config)
10 service.wait_for_deployment(show_output=True)
11 print(service.state)

\~\\AppData\\Roaming\\Python\\Python36\\site-packages\\azureml\\core\\webservice\\webservice.py in deploy_from_model(workspace, name, models, image_config, deployment_config, deployment_target, overwrite)
450
451         image = Image.create(workspace, name, models, image_config)
\--\> 452         image.wait_for_creation(True)
453         if image.creation_state != 'Succeeded':
454             raise WebserviceException('Error occurred creating image {} for service. More information can be found '

\~\\AppData\\Roaming\\Python\\Python36\\site-packages\\azureml\\core\\image\\image.py in wait_for_creation(self, show_output)
452                                       'current state: {}\\n'
453                                       'Error response from server:\\n'
\--\> 454                                       '{}'.format(self.creation_state, error_response), logger=module_logger)
455
456         print('Image creation operation finished for image {}, operation "{}"'.format(self.id, operation_state))

WebserviceException: WebserviceException:
Message: Image creation polling reached non-successful terminal state, current state: Failed
Error response from server:
StatusCode: 400
Message: Docker image build failed.
InnerException None
ErrorResponse
{
"error": {
"message": "Image creation polling reached non-successful terminal state, current state: Failed\\nError response from server:\\nStatusCode: 400\\nMessage: Docker image build failed."
}
}`
deployment docker-image azure-machine-learning-service
1个回答
0
投票

如果您使用的是 Azure ML SDK v2,这里是部署模型的文档

如果您使用的是 v1,则可以使用 Model.register 完成模型注册,而无需使用运行对象。

model = Model.register(model_name='my_model', model_path='my_model.pkl', workspace = ws)

from azureml.core.webservice import Webservice, AciWebservice
from azureml.core.image import ContainerImage

aciconfig = AciWebservice.deploy_configuration(cpu_cores=4, 
                      memory_gb=32, 
                      tags={"data": "text",  "method" : "NB"}, 
                      description='Predict something')

image_config = ContainerImage.image_configuration(execution_script="score.py", 
                      docker_file="Dockerfile",
                      runtime="python", 
                      conda_file="myenv.yml")

image = ContainerImage.create(name = "scorer-image",
                          models = [model],
                          image_config = image_config,
                          workspace = ws
                          )

service_name = 'scorer-svc'
service = Webservice.deploy_from_image(deployment_config = aciconfig,
                                        image = image,
                                        name = service_name,
                                        workspace = ws)

doc.service.get_logs() 如果您在没有中间 docker 镜像的情况下从模型部署,则非常有用。

© www.soinside.com 2019 - 2024. All rights reserved.