Summary:
- Option 1: try to create a working Conda environment, either on your own computer or in the VM; run
conda list --export my-conda-specification.yml
, and specify your Environment withEnvironment.from_conda_specification('my-env-name', 'my-conda-specification.yml')
- Option 2: create a Docker image, for example FROM mcr.microsoft.com/azureml/openmpi3.1.2-ubuntu18.04, and install your Python packages in there. Once it's working, publish the Docker image and tell Environment to use it.
More details and some links below.
- Why computing cluster is using conda to build image even though I export the file from pip?
Why MS uses Conda: unlike Pip, Conda can also control non-Python dependencies. Conda is also better at managing precompiled packages and tracking and solving their dependencies. (Under the hood, Conda uses Pip, which is why you're seeing "Pip subprocess error" in 20_image_build_log.txt.)
It is not very hard to translate Pip's requirements.txt file to something Conda understands; I think Conda can even read requirements.txt directly. That is how it is possible that you can export a requirements.txt file from Pip, and Conda reads it.
- Can I build the environment using pip?
There are two ways you can reproducibly specify the environment you need: either create a conda specification, or successfully use pip in Docker image and use the resulting Docker image.
A. Create a conda specification that successfully builds the environment.
If you have a working conda environment:
- you can run activate it and run
conda list --export conda-specification.txt
to get the specification file (it will include any pip-installed dependencies!) - you can create a new environment from that file using
conda create --name my_env_name --file conda-specification.txt
- Hopefully it is also possible to run
Environment.from_conda_specification('my-env-name', 'my-conda-specification.txt')
. The reason I'm not sure is thatconda list --export
creates a plain text file, and Environment.from_conda_specification might expect a YAML file instead.
If you're creating a YAML file to specify an environment, it probably looks like this (below) and is called something like conda-spec.yml
.
# conda-spec.yml
name: img-classification-part3-deploy-encrypted
dependencies:
- package1 # installed by `conda install`
- package2 # installed by conda
- pip:
- azureml-sdk
- matplotlib
- pandas
- azureml-opendatasets
- encrypted-inference==0.9
- azure-storage-blob
Creation, again, takes place via one of
-
conda create --name my_env_name --file my-conda-yaml.yml
-
Environment.from_conda_specification('my-env-name', 'my-conda-specification.txt')
More details in these two URLs:
- https://learn.microsoft.com/en-us/azure/machine-learning/how-to-troubleshoot-environments
- https://azure.github.io/azureml-cheatsheets/docs/cheatsheets/python/v1/environment/
B. Build a Docker image with a working environment, and tell Environment to use that Docker file.
- To get the Azure requirements, use FROM mcr.microsoft.com/azureml/openmpi3.1.2-ubuntu18.04 (or, if you need GPU, one of the image tags in https://github.com/Azure/AzureML-Containers#featured-tags)
- Example of telling Environment to use a Docker image : https://azure.github.io/azureml-cheatsheets/docs/cheatsheets/python/v1/environment/
- As there is WARNING, if I can update the conda to latest version, the experiment might not faile. Can I update the conda in the computing cluster?
I don't specifically know if you can update conda in the cluster; but I know that updating Conda should not change which packages Conda finds or (tries to) install, so this probably will not help.
I hope something of the above will help you. Good luck!
----
EDIT 2021-08-17:
- Use the correct command to export a conda env definition. I accidentally wrote the create command, instead...