tensorflow-gpu找不到GPU

时间:2020-10-07 16:58:51

标签: python tensorflow

经过多次尝试,即使我做了在此链接https://www.tensorflow.org/install/gpu;上编写的所有内容,我也无法使用我的GPU。我尝试了许多版本的Cuda(11.0 11.1,最后一个是10.1),但是TensorFlow没有检测到GPU(Geforce Gtx 1050 ti)。

import tensorflow as tf
tf.test.is_built_with_cuda()

返回True。

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

输出:

2020-10-07 20:14:11.242732: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
WARNING:tensorflow:From C:/Users/Lenovo/PycharmProjects/AI/test.py:2: 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-10-07 20:14:13.554045: 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.
2020-10-07 20:14:13.563910: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1e9683ca5f0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-07 20:14:13.564367: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-10-07 20:14:13.565594: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library nvcuda.dll
2020-10-07 20:14:13.586511: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 Ti computeCapability: 6.1
coreClock: 1.62GHz coreCount: 6 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-10-07 20:14:13.587248: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
2020-10-07 20:14:13.592223: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cublas64_10.dll
2020-10-07 20:14:13.596083: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cufft64_10.dll
2020-10-07 20:14:13.597794: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library curand64_10.dll
2020-10-07 20:14:13.602129: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusolver64_10.dll
2020-10-07 20:14:13.604848: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusparse64_10.dll
2020-10-07 20:14:13.607078: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found
2020-10-07 20:14:13.607657: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] 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-10-07 20:14:13.686263: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-10-07 20:14:13.686660: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]      0 
2020-10-07 20:14:13.686904: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0:   N 
2020-10-07 20:14:13.689990: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1e97492faf0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-10-07 20:14:13.690470: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce GTX 1050 Ti, Compute Capability 6.1

3天后,我别无选择,也不知道。您能帮我解决问题吗?


编辑:我解决了这个问题。 Tensorflow搜索'cudnn64_7.dll'文件名。如果找不到搜索到的文件名,则cuDNN无法正常工作(即使您将cuDNN文件添加到Cuda文件中)。我下载的CuDNN有一个名为“ cudnn64_8.dll”的文件。我找到该文件并将其重命名。因此TensorFlow可以找到GPU。


1 个答案:

答案 0 :(得分:0)

您可以尝试Anaconda。这是python的软件包管理器。它使您可以安装tensorflow准备好使用gpu进行处理,而不会遇到CUDA和cuDNN版本的麻烦。我将在此处留下指向Anaconda安装程序以及如何从中安装tensorflow-gpu软件包的链接。

Anaconda

Installing tensorflow-gpu from Anaconda