Auto ML model endpoint deployment (Container Instance): Error No module named 'azureml.api'

Leo, Sabato 6 Reputation points
2021-08-12T13:04:03.99+00:00

Hi,

I am trying to deploy a model trained using AutoML directly from the Portal but the deployment to Container Instance fails. From the logs I can read the errors reported below.

I am not sure what's the problem, it only appeared recently and fun fact is that if I try to deploy a model that was trained about 10 days ago it works without problem.
Did anything change in the meantime? What am I missing?

Exception in worker process
Traceback (most recent call last):
File "/var/azureml-server/routes_common.py", line 37, in <module>
from azureml.api.exceptions.ClientSideException import ClientSideException
ModuleNotFoundError: No module named 'azureml.api'

and

Traceback (most recent call last):
File "/azureml-envs/azureml_058f846b7dd22d1daecb37981c0969bb/lib/python3.6/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/azureml-envs/azureml_058f846b7dd22d1daecb37981c0969bb/lib/python3.6/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/azureml-envs/azureml_058f846b7dd22d1daecb37981c0969bb/lib/python3.6/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/azureml-envs/azureml_058f846b7dd22d1daecb37981c0969bb/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/azureml-envs/azureml_058f846b7dd22d1daecb37981c0969bb/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/azureml-envs/azureml_058f846b7dd22d1daecb37981c0969bb/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/azureml-envs/azureml_058f846b7dd22d1daecb37981c0969bb/lib/python3.6/site-packages/gunicorn/util.py", line 359, in import_app
mod = importlib.import_module(module)
File "/azureml-envs/azureml_058f846b7dd22d1daecb37981c0969bb/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/var/azureml-server/entry.py", line 1, in <module>
import create_app
File "/var/azureml-server/create_app.py", line 4, in <module>
from routes_common import main
File "/var/azureml-server/routes_common.py", line 39, in <module>
from azure.ml.api.exceptions.ClientSideException import ClientSideException
ModuleNotFoundError: No module named 'azure.ml'

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
757 questions
Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,332 questions
{count} vote

3 answers

Sort by: Most helpful
  1. romungi-MSFT 48,906 Reputation points Microsoft Employee Moderator
    2021-08-13T06:24:07.123+00:00

    @Leo, Sabato I think this is because of a recent change in the SDK, release notes are mentioned here.

    This change is causing an issue:

    azureml-defaults
    We are removing the dependency azureml-model-management-sdk==1.0.1b6.post1 from azureml-defaults.

    An issue is also reported on a different github repo.

    The workaround for now is to update your conda environment yaml file to include the package azureml-model-management-sdk under pip after azureml-defaults

    I hope this helps.

    1 person found this answer helpful.

  2. Radhakrishnan, Ramaiah 1 Reputation point
    2021-09-22T17:26:53.52+00:00

    Hello

    I also got in to this issue 3 days back when I tried to deploy a pytorch based recommender model with a newer variation. I tried with both the recommended solution - explicitly installing either the library azure-ml-api-sdk. or azureml-model-management-sdk

    Both landed on this new error

    message": "Error in entry script, AttributeError: Can't get attribute 'new_block' on <module 'pandas.core.internals.blocks' from '/azureml-envs/azureml_a9071edb452f2dedb0ab60b9e2450ad3/lib/python

    Somewhere I found that Pandas 1.3 is causing this error and 1.2 would solve it- I tried with Pandas 1.2 / 0.25 also but the "Cant get Attribute "new block" stays --

    I had to reschedule a planned demo as I never thought I would get this problem for a very similar model that is running in production.

    Any help is much appreciated -

    Thanks

    0 comments No comments

  3. Radhakrishnan, Ramaiah 1 Reputation point
    2021-09-22T20:04:06.627+00:00

    Update

    The pandas 1.2 library is working for this issue- Originally I was using it as a reference in the YML file during deployment - But I tried changing it in my environment and ran all the scripts including train and validate scripts and now the deployment worked. Hope this saves sometime for people out there who struggled like me

    Thank you

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.