对于:
conda install pytorch=1.9.0 torchvision cudatoolkit=10.2 -c pytorch -c nvidia
报错:
Solving environment: \ warning libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE failed
LibMambaUnsatisfiableError: Encountered problems while solving:
- package openblas-devel-0.2.20-h1e4b922_3 requires blas * openblas, but none of the providers can be installed
Could not solve for environment specs
The following packages are incompatible
├─ cudatoolkit 10.2** is requested and can be installed;
├─ openblas-devel is installable and it requires
│ ├─ blas * openblas, which can be installed;
│ └─ nomkl 3.0 0, which requires
│ └─ blas [* openblas|1.0 openblas], which can be installed;
├─ pin-1 is installable and it requires
│ └─ python 3.8.* , which can be installed;
└─ pytorch 1.9.0** is not installable because there are no viable options
├─ pytorch 1.9.0 would require
│ └─ blas * mkl, which conflicts with any installable versions previously reported;
├─ pytorch 1.9.0 would require
│ └─ python >=3.6,<3.7.0a0 , which conflicts with any installable versions previously reported;
├─ pytorch 1.9.0 would require
│ └─ python >=3.7,<3.8.0a0 , which conflicts with any installable versions previously reported;
├─ pytorch 1.9.0 would require
│ └─ cudatoolkit >=11.1,<11.2 , which conflicts with any installable versions previously reported;
└─ pytorch 1.9.0 would require
└─ python >=3.9,<3.10.0a0 , which conflicts with any installable versions previously reported.
问题分析及解决办法:
对于新创建的conda虚拟环境(python=3.8),conda list:
# Name Version Build Channel _libgcc_mutex 0.1 main _openmp_mutex 5.1 1_gnu blas 1.0 openblas anaconda ca-certificates 2024.9.24 h06a4308_0 intel-openmp 2023.1.0 hdb19cb5_46306 ld_impl_linux-64 2.40 h12ee557_0 libffi 3.4.4 h6a678d5_1 libgcc-ng 11.2.0 h1234567_1 libgfortran-ng 11.2.0 h00389a5_1 anaconda libgfortran5 11.2.0 h1234567_1 anaconda libgomp 11.2.0 h1234567_1 libopenblas 0.3.21 h043d6bf_0 anaconda libstdcxx-ng 11.2.0 h1234567_1 mkl 2023.1.0 h213fc3f_46344 mkl-include 2023.1.0 h06a4308_46344 ncurses 6.4 h6a678d5_0 nomkl 3.0 0 anaconda openblas-devel 0.3.21 h06a4308_0 anaconda openssl 3.0.15 h5eee18b_0 pip 24.2 py38h06a4308_0 python 3.8.20 he870216_0 readline 8.2 h5eee18b_0 setuptools 75.1.0 py38h06a4308_0 sqlite 3.45.3 h5eee18b_0 tbb 2021.8.0 hdb19cb5_0 tk 8.6.14 h39e8969_0 wheel 0.44.0 py38h06a4308_0 xz 5.4.6 h5eee18b_1 zlib 1.2.13 h5eee18b_1
根据提供的 conda list
输出,当前环境中存在一些可能导致冲突的问题。以下是一些关键点:
-
存在
blas
和openblas
库的不同版本:blas
被安装为openblas
(版本 1.0),同时还安装了libopenblas
和openblas-devel
(版本 0.3.21)。这个可能会导致冲突,尤其是PyTorch
和其他科学计算库通常依赖于某种形式的blas
。
-
nomkl
包的存在:nomkl
包的存在可能导致mkl
库无法正常工作。PyTorch
1.9.0 依赖于mkl
库,而nomkl
会避免安装mkl
,这可能是问题的根源。
-
Python 版本与 PyTorch 版本的兼容性:
- 你当前环境中的 Python 版本是
3.8.20
,这个是 PyTorch 1.9.0 支持的版本,因此 Python 版本本身不是问题。
- 你当前环境中的 Python 版本是
解决方案
我们可以采取以下步骤来解决这些依赖冲突问题。
1. 卸载 nomkl
包
首先,卸载 nomkl
,因为它阻止了 mkl
库的安装,PyTorch 需要 mkl
库来支持某些操作。
bash
复制代码
conda remove nomkl
2. 卸载冲突的 blas
和 openblas-devel
包
blas
和 openblas
是与 mkl
竞争的库。卸载这些不必要的库,以避免它们与 mkl
冲突
conda remove blas openblas-devel libopenblas
3. 安装 mkl
相关的库
确保你安装了 mkl
和 mkl-include
,这是 PyTorch 所需要的。
conda install mkl mkl-include
4. 重新安装 PyTorch 和相关包
现在,安装 PyTorch 和对应版本的 CUDA 工具包,确保没有其他依赖冲突。
conda install pytorch=1.9.0 torchvision cudatoolkit=10.2 -c pytorch -c nvidia