1.安装CUDA
这个要看自己的显卡的适配
可以参考下面的文章
参考文章
https://blog.csdn.net/Hildasu/article/details/11408649
下面是CUDA下载的地方
CUDA
https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exe_network
2.然后下载cuDNN
3.参考下面的文章
https://blog.csdn.net/Hildasu/article/details/114086497
完成将cuDNN里面的三个文件夹拖进去那个CUDA
4.找到自己的CUDA和python版本适合的Tensorflow
python版本在cmd中打上python就能看到
然后找到适合的Tensorflow
tensorflow各个版本需要的CUDA版本以及Cudnn的对应关系
相应的网址为:
https://www.tensorflow.org/install/source#common_installation_problems
https://www.tensorflow.org/install/source_windows
5.pip安装Tensorflow
现在是2021年4月22日,我的电脑是新的所以我直接用pip命令安装的
pip install tensorflow.
其他可参考
pip安装Tensorflow
cpu版本:pip install tensorflow==1.2.1 (==后面为所要安装的版本号)
gpu版本类似:pip install tensorflow-gpu==1.2.1
6.测试Tensorflow
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
print(tf.__version__)
a = tf.constant(1.)
b = tf.constant(2.)
print(a+b)
print('GPU:', tf.test.is_gpu_available())
这里就证明GPU 调用成功了,cpu的肯定能跑