首页 > 解决方案 > tensorflow2.2.0 + Cuda11.0 GPU 测试返回 False

问题描述

我正在windows-10使用 GeForce 的 PC 上工作GTX-980Ti

我安装了最新的 Nvidia 驱动程序451.67,Visual Studio 2019 版本16.6.4tensorflow-gpu 2.2.0. 然后我下载并cuda 11.0安装cuDNN8.0.1 RC2cuda11.0.

我能够验证安装并运行示例程序。

当我尝试在 anaconda 中测试它时出现问题:

>>> import tensorflow as tf
2020-07-20 23:29:09.430847: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
>>> tf.__version__
'2.2.0'
>>> print(tf.test.is_gpu_available())
WARNING:tensorflow:From <stdin>:1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2020-07-20 23:29:13.406332: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-07-20 23:29:13.418916: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x2706c6031b0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-07-20 23:29:13.422382: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-07-20 23:29:13.425719: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-07-20 23:29:13.456071: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:03:00.0 name: GeForce GTX 980 Ti computeCapability: 5.2
coreClock: 1.228GHz coreCount: 22 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 313.37GiB/s
2020-07-20 23:29:13.461916: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-07-20 23:29:13.467883: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cublas64_10.dll'; dlerror: cublas64_10.dll not found
2020-07-20 23:29:13.474696: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-07-20 23:29:13.479956: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-07-20 23:29:13.490763: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-07-20 23:29:13.493807: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cusparse64_10.dll'; dlerror: cusparse64_10.dll not found
2020-07-20 23:29:13.498571: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found
2020-07-20 23:29:13.501335: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1598] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2020-07-20 23:29:13.601860: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-07-20 23:29:13.606065: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0
2020-07-20 23:29:13.609379: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N
2020-07-20 23:29:13.615932: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x2707213a850 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-07-20 23:29:13.618721: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce GTX 980 Ti, Compute Capability 5.2
False

和:

    >>> tf.config.list_physical_devices('GPU')
2020-07-21 13:18:04.066692: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-07-21 13:18:04.096830: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:03:00.0 name: GeForce GTX 980 Ti computeCapability: 5.2
coreClock: 1.228GHz coreCount: 22 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 313.37GiB/s
2020-07-21 13:18:04.101741: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-07-21 13:18:07.858480: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cublas64_10.dll'; dlerror: cublas64_10.dll not found
2020-07-21 13:18:07.937031: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-07-21 13:18:07.981968: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-07-21 13:18:08.309451: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-07-21 13:18:08.314100: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cusparse64_10.dll'; dlerror: cusparse64_10.dll not found
2020-07-21 13:18:08.320636: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found
2020-07-21 13:18:08.325392: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1598] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
[]
>>>

                     

有人能告诉我为什么它在寻找过时的 dll 吗?我读过我可以手动添加 dll,但不建议这样做。有人对此有解决方案吗?

python 3.8.4从 python 网站安装,但anaconda给了我这个:

(base) PS C:\Windows\system32> python --version
Python 3.7.6.

可能不相关,只是想提一下。谢谢!

标签: tensorflowanacondacudnn

解决方案


请注意,Tensorflow-2.2.0onwindows不支持CUDA-11.0and CuDNN-8.0,它支持CUDA-10.1andCuDNN-7.4在他们的文档中给出。

在此处输入图像描述

在此处输入图像描述

我建议你做以下事情:

  1. 卸载tensorflow-gpu
  2. 删除所有版本的CUDACuDNN
  3. 安装CUDA-10.1CuDNN-7.4
  4. 安装tensorflow-gpu

文档=> 特别是,TensorFlow 不会在没有cuDNN64_7.dll文件的情况下加载。

笔记:


推荐阅读