Search code examples
pythoncontainersazure-container-instancesazure-machine-learning-service

Azure container instances deployment failed


I am deploying a machine learning image to Azure Container Instances from Azure Machine Learning services according to this article, but am always stuck with the error message:

Aci Deployment failed with exception: Your container application crashed. This may be caused by errors in your scoring file's init() function.
Please check the logs for your container instance xxxxxxx'.

I tried:

  1. increasing memory_gb=4 in aci_config.
  2. I did troubleshooting locally, but I could not have found any.

Below is my score.py

def init():
    global model
    model_path = Model.get_model_path('pofc_fc_model')
    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()

Solution

  • Have you registered the model 'pofc_fc_model' in your workspace using the register() function on the model object? If not, there will be no model path and that can cause failure.

    See this section on model registration: https://learn.microsoft.com/en-us/azure/machine-learning/service/how-to-deploy-and-where#registermodel