tensorflow-gpu2.x无法检测到GPU设备
1.检查
在解决问题前检查一下tensorflow是否只能检查到CPU,而无法检查到GPU,而非无法调用GPU。
import tensorflow as tfprint(tf.test.is_gpu_available())gpus = tf.config.experimental.list_physical_devices(device_type='GPU')cpus = tf.config.experimental.list_physical_devices(device_type='CPU')print(gpus, cpus)#打印结果为 #False #[] [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
2.解决方法
2.1问题一:没安装对应的cudnn和cudatoolkit依赖
解决办法:安装对应的cudnn和cudatoolkit
这个我就不重述了我博文里面有:/qq_43203949/article/details/108479784.
注意我的安装环境是:其中Driver Version: 441.83 NVIDIA-SMI 441.83没有绝对的要求。
2.2问题二:安装了对应的依赖却缺失了关键文件(cudnn64_7.dll)
如发生一下问题:(在pycharm的红色字体报告中可以看到)
Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found
解决办法:去英伟达那里下载对应的cudnn文件,并将缺失文件拷贝到对应的文件夹中即可。
这个我就不重述了,我这个也写了一个博文:
/qq_43203949/article/details/108550960.
如果觉得《tensorflow-gpu2.x无法检测到GPU设备》对你有帮助,请点赞、收藏,并留下你的观点哦!