Tensorflow未检测到GPU-添加可见的GPU设备:0

时间:2019-01-08 15:18:20

标签: tensorflow

我有一个装有NVIDIA GeForce GTX 980 Ti的系统。我安装了tensorflow,并使用tf.test.gpu_device_name()查找gpu设备。看起来它找到了gpu,但是说“添加可见的gpu设备:0”

>>> import tensorflow as tf
>>> tf.test.gpu_device_name()
2019-01-08 10:01:12.589000: I tensorflow/core/platform/cpu_feature_guard.cc:141]
 Your CPU supports instructions that this TensorFlow binary was not compiled to
use: AVX2
2019-01-08 10:01:12.855000: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1
432] Found device 0 with properties:
name: GeForce GTX 980 Ti major: 5 minor: 2 memoryClockRate(GHz): 1.228
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 5.67GiB
2019-01-08 10:01:12.862000: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1
511] Adding visible gpu devices: 0

3 个答案:

答案 0 :(得分:3)

有趣的是,您关心的0不是您将用于计数的0。准确地说,它不是“检测到0个设备”,而是“检测到0个设备”。 “添加可见设备0”,此处0是您GPU的标识。或者可以说,张量流在系统中的多个GPU之间进行区分的方式。 这是系统的输出,我敢肯定,我用完了GPU进行计算。 所以不用担心你已准备好出发!

Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.test.gpu_device_name()
2019-01-08 20:51:02.212125: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-01-08 20:51:03.199893: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties:
name: GeForce GTX 1060 with Max-Q Design major: 6 minor: 1 memoryClockRate(GHz): 1.3415
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 4.97GiB
2019-01-08 20:51:03.207308: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0
2019-01-08 20:51:04.857881: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-01-08 20:51:04.861791: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977]      0
2019-01-08 20:51:04.863796: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0:   N
2019-01-08 20:51:04.867507: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/device:GPU:0 with 4722 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 with Max-Q Design, pci bus id: 0000:01:00.0, compute capability: 6.1)
'/device:GPU:0'

答案 1 :(得分:0)

以管理员身份运行提示可以解决我的情况

答案 2 :(得分:0)

您可以尝试以下命令之一:

  1. device_lib.list_local_devices()
  2. print("可用的 GPU 数量:", len(tf.config.experimental.list_physical_devices('GPU')))

这将显示 GPU 设备及其编号。

为了解决这个问题,我的设置如下:

张量流 2.4.1

cuda 11.0.2

cudNN 8.1.0

所以首先你安装 tensorflow。然后继续使用 cuda (https://developer.nvidia.com/cuda-11.0-download-archive),从这里下载 cudNN zip 文件 -> https://developer.nvidia.com/rdp/cudnn-download 后,解压缩 cudnn64_8.dll 文件并将其粘贴到 C :\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin。 然后一切都像一个魅力。