使用tensorflow 2.4.1
当我运行程序时,我会遇到这个错误,无法使用我的gpu
。
我正在使用CUDA 11.0
、cudnn 8.0
2021-02-07 03:36:18.132005: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
WARNING:tensorflow:From D:/PycharmProjects/pythonProject/models/kpş,i.py:5: 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.
2021-02-07 03:36:19.735127: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-02-07 03:36:19.739052: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll
2021-02-07 03:36:20.715634: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1650 computeCapability: 7.5
coreClock: 1.56GHz coreCount: 16 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 119.24GiB/s
2021-02-07 03:36:20.716281: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-02-07 03:36:20.723519: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2021-02-07 03:36:20.724040: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2021-02-07 03:36:20.729436: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2021-02-07 03:36:20.731800: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2021-02-07 03:36:20.741580: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2021-02-07 03:36:20.745576: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2021-02-07 03:36:20.746657: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found
2021-02-07 03:36:20.746971: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1757] 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...
2021-02-07 03:36:20.836861: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-02-07 03:36:20.837144: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0
2021-02-07 03:36:20.837314: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N
2021-02-07 03:36:20.837493: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
我想我可以帮助您提供cudnn64_8.dll
文件(这是下载链接:https://www.dll-files.com/cudnn64_8.dll.html)。当您获得该文件时,您可以将其放入bin
目录中。例如,通常在windows平台中,您可以将其放入C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.3bin
中。
丢失的dll文件位于cuDNN文件夹中。我能够通过将cudnn64_8.dll
文件复制到CUDA文件夹(即C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6bin
)来解决此问题。
cuDNN被列为tensorflow工作的要求,您可以在这里下载。不过,您需要先注册一个开发人员帐户。
观看此视频以解决此问题,
由于CUDA文件夹中缺少Microsoft visual studio C++可复制文件,因此出现此文件未找到错误
附加
对于PyTorch in conda environment
,没有额外的CUDA和Cudnn安装,因为在键入conda install pytorch
之后,conda会将CUDA和Cudnn安装到该conda环境中。
在遵循了CuDNN的所有安装说明后,我也遇到了这个问题。问题的根本原因很简单。在安装说明中,它告诉您将<root>NVIDIACUDNNv8.x
添加到PATH
中。至少对于Tensorflow来说,这是错误的。您需要将<root>NVIDIACUDNNv8.xbin
添加到您的PATH
中。这应该能解决问题。对我来说的确如此。
我看到一些关于将cudnn64_8.dll
文件移动到C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.6bin
的答案。这之所以有效,是因为CUDA在安装PATH
时会自动将该bin目录添加到CCD_18中。因此,将cudnn64_8.dll
移动到那里可以有效地将其添加到CCD20中。
我宁愿把东西放在合适的位置,所以我更喜欢这种方式。
我想分享让我能够解决等所有问题的步骤
Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found
Could not load library cudnn_cnn_infer64_8.dll.
Could not load library cudnn_ops_infer64_8.dll.
- 首先确保已安装NVIDIA GPU的驱动程序。你可以在这里下载驱动程序
- 安装可以在此处下载的CUDA工具包
- 从这里下载cudnn-zip文件并解压缩
- 从解压缩的cudnn中,将
bin
、include
和lib
子目录中的文件复制粘贴到位于...Program FilesNVIDIA GPU Computing ToolkitCUDAv11.x
的相应bin
、include
和lib
子目录中 - 从这里下载Zlib档案并解压缩
- 将粘贴
zlibwapi.dll
从Zlib存档复制到...Program FilesNVIDIA GPU Computing ToolkitCUDAv11.x
的bin
子目录中
我也遇到了这个错误,我认为cudnn需要不同的安装。这是安装指南和所需的软件包https://developer.nvidia.com/cudnn.
*编辑->在上面的链接中,您可以下载tensorflow所需的cuddn版本,然后将它们放在所需的文件夹中,这将解决您的问题。
这将解决您的问题:
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
我也有同样的错误。这个链接中提出的解决方案对我有效。他们建议安装cuDNN,并在这里解释如何安装
就我个人而言,在上面的解释中,缺少的只是我通过Anaconda安装的ZLIB(或者更具体地说是zlibwapi)。