问题:
使用pytorch官方安装命令出现以下情况
解决:
1.查看当前使用源:
conda config --show-sources
2.删除当前使用源
红色框中的均为已添加的源,明显不够,而且还有错误的,尴尬尴尬······
重新添加源,建议使用清华源(TUNA),并且将已有的源全部删除(以防万一有错的~)
删除命令如下:
conda config --remove channels 源名称或链接
其中源名称或链接为第一步查看当前使用源查看出来的结果(我的4个需要全部删除)。例如删除第一个:
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
我的删除过程:
3.删除完成后添加清华源
命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
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/peterjc123/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
添加完成后,再次查看源,如果是以下样子,就OK啦 ! 这里应该添加了大部分的源,以后要下载的东西,这些也都基本都够用,以后下载,就不需要这么麻烦,直接从下一步安装,输入命令下载就OK!
PS:查看源命令
conda config --show-sources
4.安装pytorch
仍然使用官方命令即可
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
如果你也看到上图,那么成功就在眼前!!!
图中显示的是你要安装pytorch的同时需要安装的一系列包,那么,emmmm,没得选,只能输入 “y”
接下来,自动安装·····
有点壮观~~
到这里安装就完全结束了。。
那么来测试一下吧~
成功!没有提示“ no module named 'torch”。至此,已经安装成功 ~~~