DEV Community

Kenichiro Nakamura
Kenichiro Nakamura

Posted on

1 2

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/

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay