gpt4 book ai didi

python - 为什么 Azureml studio 处理 pip 包和 conda 包来创建环境而不是只有一个?

转载 作者:行者123 更新时间:2023-12-03 06:58:27 24 4
gpt4 key购买 nike

我正在遵循 dp-100 认证的 azure 路径,并注意到为了创建环境,一些软件包使用 conda 安装,其他软件包使用 pip 安装:

# Ensure the required packages are installed
packages = CondaDependencies.create(conda_packages=['scikit-learn','pip'],
pip_packages=['azureml-defaults'])
sklearn_env.python.conda_dependencies = packages

这是为什么呢?如果我将其更改为:

packages = CondaDependencies.create(conda_packages=['scikit-learn','pip','azureml-defaults'])
sklearn_env.python.conda_dependencies = packages

packages = CondaDependencies.create( pip_packages=['azureml-defaults','scikit-learn'])                                  
sklearn_env.python.conda_dependencies = packages

如果是这样...我应该如何决定哪些包使用 conda 以及哪些包使用 pip?

有关更多上下文,这是完整的代码块:

from azureml.core import Experiment, ScriptRunConfig, Environment
from azureml.core.conda_dependencies import CondaDependencies

# Create a Python environment for the experiment
sklearn_env = Environment("sklearn-env")

# Ensure the required packages are installed
packages = CondaDependencies.create(conda_packages=['scikit-learn','pip'],
pip_packages=['azureml-defaults'])
sklearn_env.python.conda_dependencies = packages

# Create a script config
script_config = ScriptRunConfig(source_directory='training_folder',
script='training.py',
environment=sklearn_env)

# Submit the experiment
experiment = Experiment(workspace=ws, name='training-experiment')
run = experiment.submit(config=script_config)
run.wait_for_completion()

And this is the source

最佳答案

If so... how should I decide for wich packages use conda and for wich use pip?

根据documentation :

If your dependency is available through both Conda and pip (from PyPi), use the Conda version, as Conda packages typically come with pre-built binaries that make installation more reliable.

例如:

from azureml.core.environment import CondaDependencies

myenv = Environment(name="myenv")
conda_dep = CondaDependencies()
conda_dep.add_conda_package("scikit-learn")

引用文献:Understanding Conda and Pip , Unable to access python packages installed in Azure MLAzure ML not able to create conda environment

关于python - 为什么 Azureml studio 处理 pip 包和 conda 包来创建环境而不是只有一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72695360/

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