In SDK V1, I am using a environment for compute cluster with a dockerfile string like this:
azureml_env = Environment("my_experiment")
azureml_env.python.conda_dependencies = CondaDependencies.create(
pip_packages=["pandas", "databricks-connect==10.4"],
)
dockerfile = rf"""
FROM mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu22.04:latest
RUN mkdir -p /usr/share/man/man1
RUN apt-get -y update \
&& apt-get install openjdk-19-jdk -y \
&& rm -rf /var/lib/apt/lists/*
"""
azureml_env.docker.base_image = None
azureml_env.docker.base_dockerfile = dockerfile
So I am using mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu22.04:latest where it gives me a python 3.8.
But when I switch to SDK V2, I get a python 3.10, which is not compatible with my databricks runtime that need python 3.8.
Here is my dockerfile:
FROM mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu22.04:latest
RUN mkdir -p /usr/share/man/man1
RUN apt-get -y update \
&& apt-get install openjdk-19-jdk -y \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install -r requirements.txt && rm requirements.txt
# set command
CMD ["bash"]
I call it like this in python:
azureml_env = Environment(
build=BuildContext(
path="deploy/utils/docker_context", # Where is my dockerfile and other file to copy inside
),
name="my_experiment",
)
azureml_env.validate()
self.ml_client.environments.create_or_update(azureml_env)
Why don't I get a python 3.8 but a python 3.10?
You cannot provide a
conda.yamlfile when using a Docker build context. Thus, you need to create a conda environment and a Dockerfile as shown below:Here, I am creating a conda environment first with Python version 3.8 and running the remaining commands.
conda_dependencies.yamlOutput:
And in the environment:
If you want to avoid these commands, you can try using other images with Python 3.8.