DEV Community

Kenichiro Nakamura
Kenichiro Nakamura

Posted on

Use Python 3.8 for Azure ML Custom Image

Azure Machine Learning (ML) service is great place for MLOps. As each project may require different dependencies, the service support to use custom image as its base image when running experiment.

Create & use software environments in Azure Machine Learning

There is sample Dockerfile to create custom image at Create a custom base image for ubuntu 16.04 and python 3.7.

If you want to use python 3.8, Azure ML SDK 1.16 supports python 3.8 and you can update the Dockerfile to support it.

FROM ubuntu:16.04

ARG CONDA_VERSION=4.8.3
ARG PYTHON_VERSION=3.8
ARG AZUREML_SDK_VERSION=1.16.0
ARG INFERENCE_SCHEMA_VERSION=1.1.0

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV PATH /opt/miniconda/bin:$PATH
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update --fix-missing && \
    apt-get install -y wget bzip2 && \
    apt-get install -y fuse && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*

RUN useradd --create-home dockeruser
WORKDIR /home/dockeruser
USER dockeruser

RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py38_${CONDA_VERSION}-Linux-x86_64.sh -O ~/miniconda.sh && \
    /bin/bash ~/miniconda.sh -b -p ~/miniconda && \
    rm ~/miniconda.sh && \
    ~/miniconda/bin/conda clean -tipsy
ENV PATH="/home/dockeruser/miniconda/bin/:${PATH}"

RUN conda install -y conda=${CONDA_VERSION} python=${PYTHON_VERSION} && \
    pip install azureml-defaults==${AZUREML_SDK_VERSION} inference-schema==${INFERENCE_SCHEMA_VERSION} &&\
    conda clean -aqy && \
    rm -rf ~/miniconda/pkgs && \
    find ~/miniconda/ -type d -name __pycache__ -prune -exec rm -rf {} \;
Enter fullscreen mode Exit fullscreen mode

One small but important change is miniconda installer address. It was Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh before, but now it's Miniconda3-py38_${CONDA_VERSION}-Linux-x86_64.sh for python 3.8.

The naming convention may change in the future, so checkout the valid installer download address at https://repo.anaconda.com/miniconda/

Top comments (0)