检查CUDA版本nvcc --version
在官方手册:https://tensorflow.google.cn/install/source_windows#gpu中可以看到CUDA需要10.1的版本
下载CUDA10.1
https://developer.nvidia.com/cuda-toolkit-archive
随机挑选一个幸运版本
趁着CUDA在下载的时候看一下,需要自己注册一个账号。cudnnhttps://developer.nvidia.com/cudnn
CUDA安装完成后,检查版本nvcc --version
cudnn我去查了一下发现最好是7.6以上,但是官方文档写的是7.4,不知道咋回事,打算下7.6.5。
依次复制
再打开一个文件管理器,路径为C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
把解压后的文件中的bin文件夹里的的文件复制到另一个文件夹bin下
同理对lib文件夹的文件进行操作,注意路径是.../lib/x 64
检查一下环境变量中的path是否有
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
(用的老图)
然后打开目录C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\demo_suite
shift加鼠标右键打开powershell
执行.\bandwidthTest.exe
安装成功。
打开Anaconda的prompt。
输入conda create -n tensorflow pip python=3.7
会提示是否要移除原来的Tensorflow,输入y,中间有一步需要回车一下才会开始下载。
接着输入activate tensorflow
输入pip install tensorflow-gpu==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
清华镜像太香了。根据需要改版本号就可以了,cpu版把-gpu去掉就好。
打开 Anaconda navigator。
看看ipython,Tensorflow-gpu,spyder哪个没安装就安装起来。
然后还有一个问题是在ipython中输入
import tensorflow as tf
print(tf.__version__)
出来的结果是2.3,而在spyder中是1.14,并且出来的页面的白色背景的spyder(就是我常用的spyder3,之前用1.14跳出来的是黑色背景的spyder4),应该需要在Tensorflow环境中重新下载一个Tensorflow。
在Tensorflow环境下输入conda install spyder
安装完成后输入spyder就是spyder4了(而且之前写的Tensorflow作业也一起放出来了)
不放心可以再运行一下代码看是不是2.3的
import tensorflow as tf
print(tf.__version__)
开学三周了还在重装Tensorflow,痛苦。