Tensorflow GPU Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found

Tensorflow GPU Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found

当我运行

import tensorflow as tf 
tf.test.is_gpu_available(
    cuda_only=False, min_cuda_compute_capability=None
)

我收到以下错误

第 1 步
 Move to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin
第 2 步
Rename file cusolver64_11.dll  To  cusolver64_10.dll 

 cusolver64_10.dll 

我遇到了同样的问题。事实证明,CUDA 11.0 包含 cusolver64_10.dll(这可能就是为什么他们在此处的 tensorflow 构建指南中指示 CUDA v11.0 https://www.tensorflow.org/install/source_windows)。确保同时下载 cudnn!

TL;DR 对于 Windows 上的 TensorFlow ver >= 2.4.0,请准确安装下面突出显示的 CUDA ToolkitcuDNN 版本,即那些在官方要求。(v11.0 相对于 v11.2)


Windows,撰写本文时的 TensorFlow^ 安装要求如 here

所述
  1. NVIDIA® GPU 驱动程序 —CUDA® 11.0 需要 450.x 或更高版本。

  2. CUDA® 工具包 —TensorFlow 支持 CUDA® 11 (TensorFlow >= 2.4.0)

  3. CUPTI 附带 CUDA® 工具包。

  4. cuDNN SDK 8.0.4.

  5. (可选)TensorRT 6.0 以改善某些模型推理的延迟和吞吐量。

您遇到的问题可能与CUDA® Toolkit 的版本有关。 Tensorflow 对依赖项的版本很挑剔。看看里面 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin**。您应该能够在那里找到 TensorFlow 所需的大部分 ^^ dll。您可能会注意到它包含 cusolver64_11.dll 而不是输出中所述的预期 cusolver64_10.dll

虽然上面答案中提到的重命名技巧有效,但不能保证始终可靠地工作。简单而正确的解决方案是首先安装正确的依赖项。

在撰写本文时,CUDA ToolkitcuDNN 的兼容版本是

CUDA Toolkit 11.0 (May 2020)
cuDNN v8.0.4 (September 28th, 2020), for CUDA 11.0 

从两者的大量可用版本中,列出了 here & here

尚不支持更新的版本(我从 v11.0 开始测试)。我记得几年前使用早期版本的 TensorFlow 时遇到过同样的问题。


^ 对于 ver >1.15,TensorFlow 默认包含 GPU 支持,因此需要 CUDA。当不可用时,TensorFlow 工作正常 - 它只是恢复到 CPU 执行。
** 或者你安装工具包的地方
^^ cudnn64_8.dll 附带 cuDNN SDK

对于 TensorFlow 2.4.1,如果需要安装 CUDA 11.2,重命名 hack 将起作用。我建议为 TF 2.4.1 安装 CUDA 11.0 + cuDNN 8.0.4,正如@lineage 上面写的那样,然后就不需要重命名了,你的 GPU 将被识别。

对于 TensorFlow 2.5.0,我刚刚使用 CUDA 11.2.2 + cuDNN 8.1.1 识别了我的 GPU。在这种情况下,请勿重命名 cusolver 文件。 TF 2.5.0 需要“cusolver64_11.dll”文件名。

c> python
Python 3.9.4 | packaged by conda-forge | (default, May 10 2021, 22:10:34) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2021-05-28 08:11:24.517894: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
>>> print(tf.version.VERSION)
2.5.0
>>> print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')),
...       '\nDevice: ', tf.config.list_physical_devices('GPU'))
2021-05-28 08:12:19.501812: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library nvcuda.dll
2021-05-28 08:12:19.530869: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: NVIDIA GeForce GTX 1080 with Max-Q Design computeCapability: 6.1
coreClock: 1.468GHz coreCount: 20 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 298.32GiB/s
2021-05-28 08:12:19.531377: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
2021-05-28 08:12:19.597785: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublas64_11.dll
2021-05-28 08:12:19.597992: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublasLt64_11.dll
2021-05-28 08:12:19.618849: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cufft64_10.dll
2021-05-28 08:12:19.634321: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library curand64_10.dll
2021-05-28 08:12:19.677539: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library **cusolver64_11.dll**
2021-05-28 08:12:19.731541: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusparse64_11.dll
2021-05-28 08:12:19.746271: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudnn64_8.dll
2021-05-28 08:12:19.746674: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0
Num GPUs Available:  1
Device:  [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
>>>