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.32cudaincudnn64_7.dll 到 C:Program FilesNVIDIA GPU Computing ToolkitCUDAv10.0in
复制 cudnn-10.0-windows10-x64-v7.6.5.32cudaincludecudnn.h 到 C:Program FilesNVIDIA GPU Computing ToolkitCUDAv10.0include
复制 cudnn-10.0-windows10-x64-v7.6.5.32cudalibx64cudnn.lib 到 C:Program FilesNVIDIA GPU Computing ToolkitCUDAv10.0libx64
- 添加环境变量:
将如下路径添加到环境变量path中
C:Program FilesNVIDIA GPU Computing ToolkitCUDAv10.0in
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))
参考链接:https://blog.csdn.net/qq_37277944/article/details/82717796