gpt4 book ai didi

anaconda - Azure ML 无法创建 conda 环境(退出代码 : -15)

转载 作者:行者123 更新时间:2023-12-04 14:57:41 24 4
gpt4 key购买 nike

当我尝试运行 this notebook 中定义的实验时在笔记本中,我在创建 conda env 时遇到错误。执行以下单元格时发生错误:

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()
每次运行它时,我总是面临创建 conda env 的问题,如下所示:
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
我在互联网上找不到任何有用的东西,这不是唯一失败的脚本。当我尝试运行其他实验时,有时会遇到这个问题。在上述情况下工作的一种解决方案是我将 Pandas 从 pip 移动到 conda 并且它能够创建 coonda 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]'])

# 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'])


错误消息(或来自 Azure 的日志)也没有太大帮助。如果有适当的解决方案可用,将不胜感激。
编辑:我最近开始学习使用 Azure 进行机器学习,所以如果我不确定我是否遗漏了什么?我认为示例笔记本应该可以正常工作,因此提出了这个问题。

最佳答案

简答
以前完全在你的鞋子里。此代码示例似乎有点过时。使用 this notebook作为引用,您可以尝试以下方法吗?

packages = CondaDependencies.create(
pip_packages=['azureml-defaults','scikit-learn']
)
更长的答案
Using pip with Conda并非总是一帆风顺。在这种情况下,conda 不会报告 pip 遇到的问题。解决方案是在本地创建和测试此环境,我们可以在其中获取更多信息,这至少会给您提供更多信息丰富的错误消息。
  • 安装 anaconda 或 miniconda(或使用预先安装了 conda 的 Azure ML 计算实例)
  • 创建一个名为 environment.yml 的文件,如下所示

  • name: aml_env
    dependencies:
    - python=3.8
    - pip=21.0.1
    - pip:
    - azureml-defaults
    - azureml-dataprep[pandas]
    - scikit-learn==0.24.1
  • 使用命令 conda env create -f environment.yml 创建此环境.
  • 响应任何发现的错误消息
  • 如果没有错误,请使用这个新的 environment.yml像这样的 Azure ML

  • sklearn_env = Environment.from_conda_specification(name = 'sklearn-env', file_path = './environment.yml')
    更多上下文
    我猜发生的错误是当您从 conda 环境文件中引用 pip 需求文件时。在这种情况下,conda 调用 pip install -r requirements.txt如果该命令出错,则 conda 无法报告错误。 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

    关于anaconda - Azure ML 无法创建 conda 环境(退出代码 : -15),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67639665/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com