这个错主要是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)

 

GitHub 加速计划 / te / tensorflow
184.54 K
74.12 K
下载
一个面向所有人的开源机器学习框架
最近提交(Master分支:26 天前 )
a49e66f2 PiperOrigin-RevId: 663726708 1 个月前
91dac11a This test overrides disabled_backends, dropping the default value in the process. PiperOrigin-RevId: 663711155 1 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐