tensorflow1.14.0和cuda10.0.0兼容性比较好,建议安装这两个版本
2、下载CUDNN
需要注册登录才能下载
https://developer.nvidia.com/rdp/cudnn-archive
3、安装
如果第一步安装CUDA没有修改安装路径,执行以下操作:
复制 cudnn-10.0-windows10-x64-v7.6.5.32\cuda\bin\cudnn64_7.dll 到 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
复制 cudnn-10.0-windows10-x64-v7.6.5.32\cuda\include\cudnn.h 到 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include
复制 cudnn-10.0-windows10-x64-v7.6.5.32\cuda\lib\x64\cudnn.lib 到 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64\
- 添加环境变量:
将如下路径添加到环境变量path中
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
4、TensorFlow-gpu安装
-
新建环境:
conda create -n tfgpu python=3.6 -
切换环境
conda activate tfgpu -
安装TensorFlow gpu版本
pip install -i https://pypi.mirrors.ustc.edu.cn/simple/ tensorflow-gpu==1.14.0 -
测试1
import tensorflow as tf
print(tf.test.is_gpu_available())
- 测试2
import tensorflow as tf
a = tf.constant([1.0,2.0,3.0],shape = [3], name='a')
b = tf.constant([1.0,2.0,3.0], shape = [3], name='b')
c = a +b
sess = tf.Session(config = tf.ConfigProto(log_device_placement =True))
print(sess.run(c))
4、CPU版本的安装
pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
参考链接:https://blog.csdn.net/qq_37277944/article/details/82717796