换了新电脑,重新安装环境,发现之前遇到的错误都没有再出现了,整个过程很简单。 以下过程都是在安装好anaconda、cuda以及cudnn的环境下进行的。
我的cuda版本是11.0(版本号根据自己电脑cuda的版本进行调整),如果遇到问题直接到pytorch官方进行查询你要的命令:
activate pytorch //使用conda命令 conda install pytorch torchvision cudatoolkit=11.0 -c pytorch //使用pip命令 pip install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html //lib torch Windows binaries do not support Java. Support is only available for Linux and MacOS. Download here for C++ (Release version): https://download.pytorch.org/libtorch/cu102/libtorch-win-shared-with-deps-1.6.0.zip Download here for C++ (Debug version): https://download.pytorch.org/libtorch/cu102/libtorch-win-shared-with-deps-debug-1.6.0.zip测试
//输入python进入到python环境中 import torch //这里可能会报错,需要下载一个组件(https://download.visualstudio.microsoft.com/download/pr/48431a06-59c5-4b63-a102-20b66a521863/4B5890EB1AEFDF8DFA3234B5032147EB90F050C5758A80901B201AE969780107/VC_redist.x64.exe)附网址 import torchvision //到这里依旧没有问题,安装成功