tensorflow似乎无法识别我的GPU,如何解决它?

时间:2020-05-04 20:56:09

标签: python tensorflow tensorflow2.0

我在自己的终端上尝试将tensorflow-gpu安装到新计算机和系统中,并且一切都可以完美识别我的GPU:

Nvidia测试:

nvcc  --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

但是,试图了解tensorflow是否可以识别我尝试过的GPU:

Tensorflow测试:

import tensorflow as tf
tf.test.is_gpu_available()

结果:

2020-05-04 22:51:25.687188: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-05-04 22:51:25.687914: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: 
pciBusID: 0000:06:00.0 name: GeForce RTX 2060 SUPER computeCapability: 7.5
coreClock: 1.65GHz coreCount: 34 deviceMemorySize: 7.79GiB deviceMemoryBandwidth: 417.29GiB/s
2020-05-04 22:51:25.687956: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2020-05-04 22:51:25.687972: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10
2020-05-04 22:51:25.687986: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10
2020-05-04 22:51:25.688002: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10
2020-05-04 22:51:25.688015: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10
2020-05-04 22:51:25.688029: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10
2020-05-04 22:51:25.688112: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory
2020-05-04 22:51:25.688124: 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-05-04 22:51:25.688160: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-04 22:51:25.688170: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0 
2020-05-04 22:51:25.688178: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N 
False

另一方面,遵循here的建议。我尝试了以下命令:

其他Tensorflow测试:

from tensorflow.python.client import device_lib
device_lib.list_local_devices() 

我得到以下日志。

我的日志:

2020-05-04 22:53:35.486634: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-05-04 22:53:35.487357: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: 
pciBusID: 0000:06:00.0 name: GeForce RTX 2060 SUPER computeCapability: 7.5
coreClock: 1.65GHz coreCount: 34 deviceMemorySize: 7.79GiB deviceMemoryBandwidth: 417.29GiB/s
2020-05-04 22:53:35.487403: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2020-05-04 22:53:35.487421: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10
2020-05-04 22:53:35.487436: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10
2020-05-04 22:53:35.487451: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10
2020-05-04 22:53:35.487464: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10
2020-05-04 22:53:35.487477: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10
2020-05-04 22:53:35.487564: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory
2020-05-04 22:53:35.487574: 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-05-04 22:53:35.487591: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-04 22:53:35.487598: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0 
2020-05-04 22:53:35.487604: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N 
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 12034437465466050746
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 16469163198093824972
physical_device_desc: "device: XLA_CPU device"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 5712734079173508475
physical_device_desc: "device: XLA_GPU device"
]

tensorflow是否可以识别我的GPU?一些结果告诉我True和False。请帮忙。

编辑

我做过的其他测试:

import tensorflow as tf
tf.test.is_built_with_cuda()
True

这是怎么了?

2 个答案:

答案 0 :(得分:1)

您的GPU被检测到,您只是没有正确安装所有组件。您需要这篇文章:Which TensorFlow and CUDA version combinations are compatible?。我认为您的cuda没问题,但是cudnn的安装正确,从日志来看。

答案 1 :(得分:0)

Tensorflow正在检测您的GPU,但这并不意味着它具有完全功能。

您可以在日志中看到libcuddn lib。似乎未安装在系统上。

您可以在官方文档https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html

中找到此库的安装说明。

确保您还安装了列出的所有依赖项:https://www.tensorflow.org/install/gpu