使用conda时出现Solving environment: failed with initial frozen solve. Retrying with flexible solve错误

使用conda安装pytorch 出现了各种各样的错误。尝试了网上各种办法,最后我是这么解决的。
首先添加镜像源,在终端运行以下代码

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/

去pytorch官网找到你对应的下载版本
pytorch官网
在这里插入图片描述
你可以看到这上面的图,你要找到自己对应的版本,例如我的电脑上cuda是11.1版本的(向下兼容)

conda install pytorch torchvision torchaudio cudatoolkit=10.2

后面的 -c pytorch 要删掉,这样才会到镜像源下载
在这里插入图片描述
接着,在终端运行下载指令:

conda install pytorch torchvision torchaudio cudatoolkit=11.1 

检查终端是否是在镜像源下载的
如果不是在镜像源下载的,最后一列会显示pytorch或者default

before
    package                    |            build
    ---------------------------|-----------------
    cudatoolkit-10.1.243       |       h6bb024c_0       347.4 MB  pytorch
    pytorch-1.4.0              |py3.7_cuda10.1.243_cudnn7.6.3_0       432.9 MB  pytorch
    torchvision-0.5.0          |       py37_cu101         9.1 MB  pytorch
    ------------------------------------------------------------
                                           Total:       789.4 MB

如果是在镜像源下载的,最后一列会显示镜像源的地址
after
The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
_pytorch_select-0.2        |            gpu_0           2 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cudatoolkit-10.0.130       |                0       261.2 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cudnn-7.6.5                |       cuda10.0_0       165.0 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl-2019.4                 |              243       131.2 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pytorch-1.3.1              |cuda100py37h53c1284_0       169.0 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
torchvision-0.4.2          |cuda100py37hecfc37a_0         6.4 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
------------------------------------------------------------
                                       Total:       732.8 MB

由于我已经下载完成,上面是我找的下载过程中会显示的内容,所以上面显示的信息可能与我下载的版本不一致。
如果在镜像源下载的,大概率就会下载成功了。如果是到官网下,可能会因为网络问题而出现各种奇奇怪怪的错误而导致下载失败。


下载完之后发现cuda不能用,下载的是cpu的版本,上网查了下资料才知道可能是镜像源里面没有cuda的版本,所以你就需要重新去别的地方下载了。

在终端输入一下命令:

pip install torch==1.8.1+cu102 torchvision==0.9.1+cu102 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值