Search code examples
azuremachine-learningdeploymentpipdevelopment-environment

Azure: How to create an environment where the VM has a special package installed?


I am about to deploy a model on Azure but the model needs a special package installed on Ubuntu. My model is written in python and I have a python-wrapper installed (and other necessary pip packages) already in the environment.

The challenge is that the wrapper needs the special package to be installed on the Ubuntu. How and at what point I need to specify what packages I want to be installed on Ubuntu when creating the environment? The package is not a default one.


Solution

  • The following code snippet helped me to solve this. Just substitute the package you want to install into "<'package-1'>".

    FROM <prebuilt docker image from MCR>
    
    # Switch to root to install apt packages
    USER root:root
    
    RUN apt-get update && \
        apt-get install -y \
        **<package-1>** \
        ... 
        <package-n> && \
        apt-get clean -y && \
        rm -rf /var/lib/apt/lists/*
    
    # Switch back to non-root user
    USER dockeruser
    

    The complete tutorial can be found here: https://learn.microsoft.com/en-us/azure/machine-learning/how-to-extend-prebuilt-docker-image-inference