1.版本选择
cuda版本:11.0
tensorflow版本:2.4.0-gpu
pytorch版本:1.7.1
1.1cuda与tensorflow版本的对应关系参考:https://tensorflow.google.cn/install/source_windows#gpu
1.2cuda与pytorch版本的超全对应关系参考:https://download.pytorch.org/whl/torch_stable.html
2.想了解更多,可参考
https://waitfof.blog.csdn.net/article/details/120067750
2.cuda+cudnn安装
参考之前写的一篇安装教程,当时安装的是11.2的,不过几乎一样,其中配置环境变量是比较详细的
3.tensorflow安装
3.1 安装参考
参考:https://blog.csdn.net/qq_43215538/article/details/123852028,里面也有关于cuda和cudnn安装的内容
3.2 出现过的报错
ERROR: Could not find a version that satisfies the requirement tensorflow-gpu==2.4.0 (from versions: none)
解决办法:这时自己测试了一下下面的办法
https://blog.csdn.net/JineD/article/details/124774570
但发现自己输入python的语句没有反应,后面发现自己直接在命令行输出python都不能输入代码,但其他的虚拟环境还是可以的,然后发现是自己在创建虚拟环境的时候,输入的是
conda create -n xxx
但需要conda create -n xxx python=xxx(需要的版本号)才行
4.pytorch安装
4.1 参考以下网站,来找cuda所对应torch torchvision版本
https://download.pytorch.org/whl/torch_stable.html
其中torch torchvision之间也有对应关系,参考pypi里的torchvision
https://pypi.org/project/torchvision/0.13.1/
4.2 依次进行安装
#安装torch
pip install torch==1.7.1
#发现报错了 ERROR: torch has an invalid wheel, .dist-info directory not found
#参考https://blog.csdn.net/lansebingxuan/article/details/124010085,安装的直接是带有gpu的torch
pip install torch==1.7.1 -f https://download.pytorch.org/whl/torch_stable.html
#安装成功torch,进行安装torchvision,先试了
pip install torchvision==0.8.2
#发现这个代码报错了,说找不到这个版本,pypi上有这个版本呀,尝试用conda
conda install torchvision==0.8.2
#还是不行,搜索发现,采用如下:
conda install torchvision==0.8.2 -c pytorch #也是pytorch官网安装用的指令
#然后就可以成功啦!
4.3 验证可行性
import torch
print(torch.cuda.is_available())
能输出True即可
5.安装pytorch出现的报错
ERROR: torch has an invalid wheel, .dist-info directory not found
https://blog.csdn.net/lansebingxuan/article/details/124010085
6.使用VSCODE出现的报错
参考另外一个文章