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))
參考鏈接:https://blog.csdn.net/qq_37277944/article/details/82717796