无法使用tensorflow和pytorch创建conda环境

2024-09-30 08:15:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图创建一个包含tensorflow和pytorch的conda环境。举个简单的例子,我正在跑步

conda env create -n test -f test-env.yaml

使用以下test-env.yaml文件:

channels:
- conda-forge
- defaults
- pyviz

dependencies:
- python>=3.7,<3.8
- tensorflow>=2.0.0,<2.4.0
- pytorch>=1.0.0,<2.0.0
name: my_environment

我在抱怨冲突时遇到以下长时间错误:

$ conda env create -n test -f test-env.yaml
Collecting package metadata (repodata.json): done
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package _libgcc_mutex conflicts for:
pytorch[version='>=1.0.0,<2.0.0'] -> _openmp_mutex[version='>=4.5'] -> _libgcc_mutex[version='*|0.1',build='conda_forge|main|main']
python[version='>=3.7,<3.8'] -> libgcc-ng[version='>=9.3.0'] -> _libgcc_mutex[version='*|0.1',build='conda_forge|main']

Package python conflicts for:
tensorflow[version='>=2.0.0,<2.4.0'] -> python[version='2.7.*|3.6.*|3.7.*|3.8.*']
python[version='>=3.7,<3.8']
tensorflow[version='>=2.0.0,<2.4.0'] -> tensorboard[version='>=2.3.0'] -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.8,<3.9.0a0|>=3|>=3.2|>=3.5|>=3.7,<3.8.0a0']
pytorch[version='>=1.0.0,<2.0.0'] -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0']
pytorch[version='>=1.0.0,<2.0.0'] -> cffi -> python[version='2.7.*|3.5.*|3.6.*|3.6.12|3.6.12|3.7.9|3.6.9|3.6.9|3.6.9|3.6.9|>=3.5,<3.6.0a0|3.4.*|3.9.*|>=3.5|3.8.*|3.7.*|>=3.7|>=3.6,<3.7|>=3',build='1_73_pypy|3_73_pypy|4_73_pypy|5_73_pypy|2_73_pypy|0_73_pypy']

Package setuptools conflicts for:
tensorflow[version='>=2.0.0,<2.4.0'] -> tensorboard[version='>=2.3.0'] -> setuptools[version='>=41.0.0|>=41.4']
python[version='>=3.7,<3.8'] -> pip -> setuptools

Package numpy conflicts for:
tensorflow[version='>=2.0.0,<2.4.0'] -> tensorboard[version='>=2.3.0'] -> numpy[version='>=1.12.0|>=1.16|>=1.16.6,<2.0a0|>=1.16.1']
pytorch[version='>=1.0.0,<2.0.0'] -> numpy[version='>=1.11.3,<2.0a0|>=1.16.6,<2.0a0|>=1.19.5,<2.0a0|>=1.19.4,<2.0a0|>=1.14.6,<2.0a0']

Package cudatoolkit conflicts for:
pytorch[version='>=1.0.0,<2.0.0'] -> cudnn[version='>=7.6,<8.0a0'] -> cudatoolkit[version='11.0|11.0.*|>=10.0,<10.1|>=10.1,<10.2|>=9.0,<9.1|>=9.2,<9.3|>=10.2,<10.3|11.2|11.2.*|11.1|11.1.*|9.0.*|8.0.*']
pytorch[version='>=1.0.0,<2.0.0'] -> cudatoolkit[version='10.0.*|10.0|10.0.*|10.1|10.1.*|10.2|10.2.*|9.2|9.2.*|>=10.1.243,<10.2.0a0|>=9.2,<9.3.0a0|>=10.0.130,<10.1.0a0|9.2.*|>=9.0,<9.1.0a0|>=8.0,<8.1.0a0']

Package _openmp_mutex conflicts for:
pytorch[version='>=1.0.0,<2.0.0'] -> _openmp_mutex[version='>=4.5']
pytorch[version='>=1.0.0,<2.0.0'] -> mkl[version='>=2020.4,<2021.0a0'] -> _openmp_mutex=[build=*_llvm]The following specifications were found to be incompatible with your system:

  - feature:/linux-64::__glibc==2.17=0
  - pytorch[version='>=1.0.0,<2.0.0'] -> __glibc[version='>=2.17,<3.0.a0']
  - pytorch[version='>=1.0.0,<2.0.0'] -> magma[version='>=2.5.4,<2.5.5.0a0'] -> __glibc[version='>=2.17']

Your installed version is: 2.17

Note that strict channel priority may have removed packages required for satisfiability.

如果我将channel_priority设置为flexible而不是strict,它确实可以工作。但是,如果可能的话,我真的希望它能以严格的通道优先级工作。有什么办法使它起作用吗

以下是conda info的输出:

$ conda info

     active environment : base
    active env location : /home/kgullikson/miniconda3
            shell level : 1
       user config file : /home/kgullikson/.condarc
 populated config files : /home/kgullikson/.condarc
          conda version : 4.9.2
    conda-build version : 3.20.3
         python version : 3.6.11.final.0
       virtual packages : __cuda=11.2=0
                          __glibc=2.17=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/kgullikson/miniconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/pyviz/linux-64
                          https://conda.anaconda.org/pyviz/noarch
                          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
                          https://conda.anaconda.org/kgullikson/linux-64
                          https://conda.anaconda.org/kgullikson/noarch
          package cache : /home/kgullikson/miniconda3/pkgs
                          /home/kgullikson/.conda/pkgs
       envs directories : /home/kgullikson/miniconda3/envs
                          /home/kgullikson/.conda/envs
               platform : linux-64
             user-agent : conda/4.9.2 requests/2.25.1 CPython/3.6.11 Linux/3.10.0-1160.11.1.el7.x86_64 centos/7.6.1810 glibc/2.17
                UID:GID : 207402735:207400513
             netrc file : None
           offline mode : False

和我的.condarc

channels:
  - conda-forge
  - pyviz
  - defaults
  - kgullikson
conda-build:
  root-dir: ~/conda-builds
  skip_existing: true
pip_interop_enabled: false
channel_priority: strict

更新:

仔细阅读有关conda的文档,似乎这实际上是严格通道优先级的预期行为。 https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html

即:

With strict channel priority, packages in lower priority channels are not considered if a package with the same name appears in a higher priority channel

所以这里的问题是,实际上conda forge中有tensorflow软件包,只是没有一个能满足我使用tensorflow 2的要求。考虑到他们正在敦促人们使用strict,并计划将其作为conda 5的默认设置,这似乎有问题


Tags: httpsenvhomeforversionlinuxtensorflowanaconda

热门问题