pytorch安装
最好在anaconda环境下安装,因为anaconda自带cuda和cudnn,无需另外单端安装。因为conda本来就可以很好的管理不同环境,所以可以新建环境安装,也可以在base环境安装。
在官网安装比较慢,因为是外网,除非你连着VPN,否则甚至有可能报错。可以用清华镜像源,不用等那么久。
配置清华源:
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.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes#下载时显示文件来源
参考这篇https://blog.csdn.net/yunken28/article/details/105035577/
OSError: [WinError 126] 找不到指定的模块。报这个错的时候按提示安装一个c++环境,因为底层调用dll的时候没有c++环境无法实现。
验证是否安装成功,进入安装的环境下,命令行收入 python,再输入 import torch,如果没有报错,说明安装成功。