Error in file while deploying a machine learning model through python

Senthil Murugan RAMACHANDRAN 21 Reputation points

I have trained a machine learning model through python locally and I'm trying to deploy it to Azure with inference cluster. I'm able to train, upload data, register model but I'm unable to deploy the model. It's throwing path error but I have tried all the possible paths for my model. What is the correct path to the model? I have attached the error and code below for your reference. Any help is appreciated. Thanks a lot.

"code": "KubernetesDeploymentFailed",
"statusCode": 400,
"message": "Kubernetes Deployment failed",
"code": "CrashLoopBackOff",
"message": "Error in entry script, FileNotFoundError: [Errno 2] No such file or directory: 'azureml-models/amlstudio-mlpredictionep01/1/sklearn_ml_exp', please run print(service.get_logs()) to get details."

Here is my file:

def init():
global model
model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'sklearn_ml_exp')
model = joblib.load(model_path)

def run(raw_data):
data = np.array(json.loads(raw_data)['data'])
y_hat = model.predict(data)
return y_hat.tolist()

I registered the model with:

model = Model.register(workspace=ws,
model_path='outputs/prediction-model.pickle', # local path
description='Prediction model',
tags={'data-format': 'CSV'},

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,230 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. GiftA-MSFT 11,141 Reputation points

    Hi, looks like you need to specify the correct model path that you used when you registered. It should look like this sklearn_mnist_model.pkl. The following document provides information on how to locate models in your entry script. Hope this helps!

    1 person found this answer helpful.