这个错主要是tensorflow的版本对应的cuda版本不对导致的
例如我安装的tensorflow-gpu版本是2.1.0, cuda安装的是10.2结果报了
Could not load dynamic library 'cudart64_101.dll'
这个101表示对应的cuda版本应该是10.1,只要移除10.2版本的cuda,重新安装10.1版本的就行, cudnn也要一并修改到对应的版本
tensorflow的版本可以用 print(tf.__version__) 查询
测试代码
import tensorflow as tf
print(tf.__version__)
print(tf.__path__ )
print('GPU',tf.test.is_gpu_available())
print(tf.config.list_physical_devices('GPU'))
a = tf.constant(1)
b = tf.constant(1)
c = tf.add(a, b)
print(c)
打印结果:
GPU True
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
tf.Tensor(2, shape=(), dtype=int32)