Azure ML not able to create conda environment (exit code: -15) - anaconda

When I try to run the experiment defined in this notebook in notebook, I encountered an error when it is creating the conda env. The error occurs when the below cell is executed:
from azureml.core import Experiment, ScriptRunConfig, Environment
from azureml.core.conda_dependencies import CondaDependencies
from azureml.widgets import RunDetails
# Create a Python environment for the experiment
sklearn_env = Environment("sklearn-env")
# Ensure the required packages are installed (we need scikit-learn, Azure ML defaults, and Azure ML dataprep)
packages = CondaDependencies.create(conda_packages=['scikit-learn','pip'],
pip_packages=['azureml-defaults','azureml-dataprep[pandas]'])
sklearn_env.python.conda_dependencies = packages
# Get the training dataset
diabetes_ds = ws.datasets.get("diabetes dataset")
# Create a script config
script_config = ScriptRunConfig(source_directory=experiment_folder,
script='diabetes_training.py',
arguments = ['--regularization', 0.1, # Regularizaton rate parameter
'--input-data', diabetes_ds.as_named_input('training_data')], # Reference to dataset
environment=sklearn_env)
# submit the experiment
experiment_name = 'mslearn-train-diabetes'
experiment = Experiment(workspace=ws, name=experiment_name)
run = experiment.submit(config=script_config)
RunDetails(run).show()
run.wait_for_completion()
Everytime I run this, I always faced the issue of creating the conda env as below:
Creating conda environment...
Running: ['conda', 'env', 'create', '-p', '/home/azureuser/.azureml/envs/azureml_000000000000', '-f', 'azureml-environment-setup/mutated_conda_dependencies.yml']
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Installing pip dependencies: ...working...
Attempting to clean up partially built conda environment: /home/azureuser/.azureml/envs/azureml_000000000000
Remove all packages in environment /home/azureuser/.azureml/envs/azureml_000000000000:
Creating conda environment failed with exit code: -15
I could not find anything useful on the internet and this is not the only script where it fail. When I am try to run other experiments I have sometimes faced this issue. One solution which worked in the above case is I moved the pandas from pip to conda and it was able to create the coonda env. Example below:
# Ensure the required packages are installed (we need scikit-learn, Azure ML defaults, and Azure ML dataprep)
packages = CondaDependencies.create(conda_packages=['scikit-learn','pip'],
pip_packages=['azureml-defaults','azureml-dataprep[pandas]'])
# Ensure the required packages are installed (we need scikit-learn, Azure ML defaults, and Azure ML dataprep)
packages = CondaDependencies.create(conda_packages=['scikit-learn','pip','pandas'],
pip_packages=['azureml-defaults','azureml-dataprep'])
The error message (or the logs from Azure) is also not much help. Would apprecite if a proper solution is available.
Edit: I have recently started learning to use Azure for Machine learning and so if I am not sure if I am missing something? I assume the example notebooks should work as is hence raised this question.

short answer
Totally been in your shoes before. This code sample seems a smidge out of date. Using this notebook as a reference, can you try the following?
packages = CondaDependencies.create(
pip_packages=['azureml-defaults','scikit-learn']
)
longer answer
Using pip with Conda is not always smooth sailing. In this instance, conda isn't reporting up the issue that pip is having. The solution is to create and test this environment locally where we can get more information, which will at least will give you a more informative error message.
Install anaconda or miniconda (or use an Azure ML Compute Instance which has conda pre-installed)
Make a file called environment.yml that looks like this
name: aml_env
dependencies:
- python=3.8
- pip=21.0.1
- pip:
- azureml-defaults
- azureml-dataprep[pandas]
- scikit-learn==0.24.1
Create this environment with the command conda env create -f environment.yml.
respond to any discovered error message
If there' no error, use this new environment.yml with Azure ML like so
sklearn_env = Environment.from_conda_specification(name = 'sklearn-env', file_path = './environment.yml')
more context
the error I'm guessing that's happening is when you reference a pip requirements file from a conda environment file. In this scenario, conda calls pip install -r requirements.txt and if that command errors out, conda can't report the error.
requirements.txt
scikit-learn==0.24.1
azureml-dataprep[pandas]
environment.yml
name: aml_env
dependencies:
- python=3.8
- pip=21.0.1
- pip:
- -rrequirements.txt

What worked for me looking at the previous notebook 05 - Train Models.ipynb:
packages = CondaDependencies.create(conda_packages=['pip', 'scikit-learn'],
pip_packages=['azureml-defaults'])
You have to:
Remove 'azureml-dataprep[pandas]' from pip_packages
Change the order of conda_packages - pip should go first

Related

Specifying --use-deprecated=legacy-resolver in conda YAML file

I'm creating an environment in an Azure DevOps pipeline from a .yml file. However, one of my modules has dependency issues, causing conda env create -n env-name --file conda.yml to get stuck. I know that I need to use --use-deprecated=legacy-resolver but since I'm creating the environment from a YAML file I don't know how to specify it in my YAML file (rather than directly running pip install).
channels:
- conda-forge
- nodefaults
dependencies:
- python=3.9.12
- pip>=19.0
- pip:
- numpy==1.22.0
- pandavro
- scikit-learn
- ipykernel
- pyspark
- mlflow
- mltable
I've tried adding [--use-deprecated=legacy-resolver] after one of my modules (e.g. pandavro [--use-deprecated=legacy-resolver]) but it seems like Conda doesn't recognize this syntax.
It seems like this feature hasn't yet been implemented, based on these posts:
https://github.com/conda/conda/issues/3763
https://github.com/conda/conda/issues/6805
The workaround that worked for me was removing all pip dependencies from my conda.yml file (i.e. all lines beginning with and including -pip:) and instead putting them in a separate requirements.txt file. I then added another step to my ADO pipeline to run pip install -r requirements.txt --use-deprecated=legacy-resolver.

Weird error in creating conda environment from yml file? (PackagesNotFoundError for the yml file itself)

I'm reinstalling Conda after a PC factory reset and trying to re-create an old conda environment from a yml file that I created by
conda env export --prefix $path_to_old_env_dir > voice_dep.yml
The resulting yml file looks ok to me, here's what it looks like:
name: voiceeda
channels:
- defaults
- conda-forge
dependencies:
- ca-certificates=2022.12.7=h5b45459_0
- libsqlite=3.40.0=hcfcfb64_0
- openssl=1.1.1s=hcfcfb64_1
- pip=22.3.1=pyhd8ed1ab_0
- python=3.9.13=h6244533_2
- setuptools=66.1.1=pyhd8ed1ab_0
- sqlite=3.40.0=hcfcfb64_0
- tzdata=2022g=h191b570_0
- ucrt=10.0.22621.0=h57928b3_0
- vc=14.3=hb6edc58_10
- vs2015_runtime=14.34.31931=h4c5c07a_10
- wheel=0.38.4=pyhd8ed1ab_0
- pip:
- anyio==3.6.2
- argon2-cffi==21.3.0
- argon2-cffi-bindings==21.2.0
- arrow==1.2.3
...
but when I try to run
conda create -n voiceeda -f voice_dep.yml
The following odd error occurs.
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- voice_dep.yml
I'd understand if it wasn't finding a particular package, I can remove versions etc. if so, but why is it saying it can't find the yml file itself? I'm very confused, wondering if I missed a crucial setup step during conda installation or smth? I'm on Windows 10, and installed anaconda to a D drive (conda version 23.1.0 & Python 3.9.13.).
Any help would be much appreciated, thank you!

Cannot install tensorflow-deps for Apple Silicon

I'm trying to set-up by Apple Silicon Mac to be able to train tf models using its GPU.
I tried following the official instructions but I am getting the following error:
>>> conda install -c apple tensorflow-deps
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- tensorflow-deps
Current channels:
- https://conda.anaconda.org/apple/osx-64
- https://conda.anaconda.org/apple/noarch
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://conda.anaconda.org/conda-forge/osx-64
- https://conda.anaconda.org/conda-forge/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Not sure if it should matter but I didn't install Miniforge because I already have Anaconda installed comprehensively. Surely, this can't be the reason? (I didn't want to install Miniforge not to mess up my env by having multiple Conda installations).
I did add the "apple" channel in the Navigator manually and the package does seem to be there:
https://anaconda.org/apple/tensorflow-deps
What am I missing here?
I also struggled with this for a while. The only way I was able to get a successful environment set up was indeed installing conda through mini forge. Based on this link I believe this is because of the other packages Anaconda pre-installs that are not ARM compatible.
I followed this thread to remove my Anaconda installation. Once that is done the instructions you linked should be successful.

Error while trying to install nvcc in conda

I am trying to install nvcc into a conda environment. The output is as follows:
(pytorch_build) user#host:~/pytorch_git/pytorch$ conda install -c nvidia nvcc_linux-64
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: path_to_conda/miniconda3/envs/pytorch_build
added / updated specs:
- nvcc_linux-64
The following NEW packages will be INSTALLED:
nvcc_linux-64 nvidia/linux-64::nvcc_linux-64-10.1-hf484d3e_0
The following packages will be SUPERSEDED by a higher-priority channel:
certifi conda-forge::certifi-2020.4.5.1-py37h~ --> pkgs/main::certifi-2020.4.5.1-py37_0
Proceed ([y]/n)?
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
ERROR conda.core.link:_execute(700): An error occurred while installing package 'nvidia::nvcc_linux-64-10.1-hf484d3e_0
'.
Rolling back transaction: done
[Errno 2] No such file or directory: 'path_to_conda/miniconda3/pkgs/nvcc_linux-64-10.1-hf484d3e_
0/bin/nvcc'
()
I checked manually and 'path_to_conda/miniconda3/pkgs/nvcc_linux-64-10.1-hf484d3e_
0/bin/nvcc' does exist.
I tried cleaning the conda package cache but that didn't help either. Next thing I'm removing the entire environment and add nvcc to the list of packages added at first.
Any else what else I might try? Please let me kow if/which additional information is required.
UPDATE
I removed the entire environment and now I'm getting
File /usr/lib64/stubs/libcuda.so doesn't exist
I'm already looking for solutions with this new problem but would appreciate any help.

How to install deprecated/unsupported Python 3.4 on conda environment?

Since the deprecation of Python 3.4, conda has removed it from its package list. Is there a way, however, that I can install it?
I need it in order to use software written in this older version.
EDIT:
My question is different than the suggested duplicate one, because I am referring to deprecated and unsupported versions. I already know how to create a conda environment with a specific python version, but executing:
conda create --name py34env python=3.4
results in error (listed in the end), which is due to the lack of the package for Python 3.4 .
One can see the currently supported versions of Python by executing: conda search python and can confirm that Python 3.4 is not on the list.
This is the output of the error when trying to create a Python 3.4 conda enviroment:
$ conda create --name py34env python=3.4
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- python=3.4
Current channels:
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
When Anaconda dropped it's free channel (technically, Conda 4.7+ just no longer looks there), this resulted in some older package versions that had never been ported to main no longer being accessible.
Option 1: Globally enable free channel searching
However, there is an option to restore access to the free channel, namely restore_free_channel.
# Not generally recommended
conda config --set restore_free_channel True
conda create -n py34 python=3.4
This isn't generally recommended (see blog post), but if you will be working in Python v3.4 frequently and will require other older compatible packages, it might be the best option.
Option 2: Temporarily include free channel
A more temporary solution is to include the free channel using the ad hoc --channel,-c argument. For example,
# slightly better
conda create -n py34 -c defaults -c free python=3.4
Note that I include defaults prior to free so that the latter will only be used if the package cannot be sourced from the former. This assumes the channel_priority setting is set to flexible (the default).
Option 3: Use Conda Forge
Alternatively, Conda Forge has Python v3.4.5, and that won't force you to change a global configuration option.
conda create -n py34 -c conda-forge python=3.4

Resources