【问题标题】:When deploying an ml model using vscode I get an error docker image build failed使用 vscode 部署 ml 模型时出现错误 docker image build failed
【发布时间】:2020-03-26 11:40:56
【问题描述】:

我正在关注本教程VSCODE tensorflow model deployment on Azure。 在这里,我尝试部署一个简单的决策树模型而不是 tensorflow 模型。我创建了一个这样的 train.py 文件

import pandas as pd
from sklearn.tree import DecisionTreeClassifier
import pickle
import os
import joblib

data=pd.read_csv('CreditCardWeka.csv')
model=DecisionTreeClassifier()
Y=data['Class']
del data['Class']
X=data
model.fit(X,Y)
os.makedirs('./outputs/model', exist_ok = True)
joblib.dump(model, './outputs/model/dec_model.sav')

在此之后我创建一个计算,创建一个运行配置并选择此文件。之后我创建一个实验并运行它并下载输出。我能够下载输出,直到它工作。 在此之后,我能够成功注册我的模型,当我尝试将其部署为“Azure 容器服务”时,它会要求 score.py,而这是

import os
import joblib
import json
import time
import sklearn
# Called when the deployed service starts
from azureml.core.model import Model

def init():
    global model

    # Get the path where the deployed model can be found.
    # load models
    model_root = Model.get_model_path('decision-tree-model')
    model = joblib.load(os.path.join(model_root, 'dec-model.sav'))

# Handle requests to the service
def run(data):
    try:
        # Pick out the text property of the JSON request.
        # This expects a request in the form of {"text": "some text to score for sentiment"}
        data = json.loads(data)
        prediction = model.predict(data['X'])
        #Return prediction
        return prediction
    except Exception as e:
        error = str(e)
        return error

它还要求一个 yml 文件是这样的

name: decision-tree
channels:
  - defaults
dependencies:
  - python
  - sklearn
  - joblib
  - pip
  - pip:
    - azureml-defaults

在此之后,当它开始创建 Docker 映像时,它会失败并且错误是“Docker 映像构建失败”。 我该如何解决这个问题?

【问题讨论】:

    标签: python azure docker visual-studio-code azure-machine-learning-service


    【解决方案1】:

    在 yml 文件中,尝试将 sklearn 更改为 scikit-learn。

    如果仍然失败,请尝试详细的故障排除说明以获取更多日志:https://docs.microsoft.com/en-us/azure/machine-learning/how-to-troubleshoot-deployment

    【讨论】:

      猜你喜欢
      • 2020-01-05
      • 2011-02-05
      • 1970-01-01
      • 2017-05-23
      • 1970-01-01
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      相关资源
      最近更新 更多