Skip to content
Advertisement

AzureML Environment for Inference : can’t add pip packages to dependencies

I can’t find the proper way to add dependencies to my Azure Container Instance for ML Inference.

I basically started by following this tutorial : Train and deploy an image classification model with an example Jupyter Notebook

It works fine.

Now I want to deploy my trained TensorFlow model for inference. I tried many ways, but I was never able to add python dependencies to the Environment.

From the TensorFlow curated environment

Using AzureML-tensorflow-2.4-ubuntu18.04-py37-cpu-inference :

JavaScript

I get the following log :

JavaScript

From a Conda specification

Same as before, but with a fresh environment from Conda specification and changing the env_version number :

JavaScript

with my-env.yml :

JavaScript

I get this log :

JavaScript

I really don’t know what I’m missing, and I’ve been searching for too long already (Azure docs, SO, …).

Thanks for your help !

Edit : Non-exhaustive list of solutions I tried :

Advertisement

Answer

OK, I got it working : I started over from scratch and it worked.

I have no idea what was wrong in all my preceding tries, and that is terrible.

Multiple problems and how I (think I) solved them :

  • joblib : I actually didn’t need it to load my Keras model. But the problem was not with this specific library, rather that I couldn’t add dependencies to the inference environment.
  • Environment : finally, I was only able to make things work with a custom env : Environment.from_conda_specification(name=version, file_path="conda_dependencies.yml") . I haven’t been able to add my libraries (or specify a specific package version) to a “currated environment”. I don’t know why though…
  • TensorFlow : last problem I had was that I trained and registered my model in AzureML Notebook’s azureml_py38_PT_TF kernel (tensorflow==2.7.0), and tried to load it in the inference Docker image (tensorflow==2.4.0). So I had to specify the version of TensorFlow I wanted to use in the inference image (which required the previous point to be solved).

What finally worked :

  • notebook.ipynb
JavaScript
  • conda_dependencies.yml
JavaScript
  • score.py
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement