新的 Tensorflow 2.4 GPU 问题

New Tensorflow 2.4 GPU issues

问题

Tensorflow 2.4.1 无法识别我的 GPU,即使我已按照 the official instructions from Tensorflow as well as the ones from NVIDIA for CUDA and NVIDIA for cuDNN 将其安装到我的计算机中。我也在 conda 中安装了它(我不确定是否需要它?)。

当我尝试 official way to check if TF 使用 GPU 时,我得到 0:

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

Num GPUs Available: 0

规格

硬件:

我的 NVIDIA 满足要求 specified by Tensorflow

软件

我如上所述安装了 CUDA(带有 CUPTI)和 cuDNN,所以我得到:

在 conda 环境中我有:

并且我为 conda 安装了额外的 cudatoolkit==11.0cudnn==8.0,如前所述 here

遵循的程序:

当我没有 conda 额外的包时它不起作用,即使我安装了那些额外的包它仍然不起作用。

经过相当多的广泛研究,它终于在我的电脑上运行了:最新版本的组件(即 CUDA 11.2cuDNN 8.1.0)未经测试,不能确保在任务组 2.4.1。因此,这是我的最终配置:

  1. nvidia-drivers-460.39CUDA 11.2 位司机。但是,您仍然可以安装 CUDA 11.0 runtime 并从 official NVIDIA archive for CUDA 获取它。按照安装说明进行操作仍然是强制性的(即添加路径变量等)。
  2. cuDNN 库需要在版本 8.0.4 上。您也可以从 official NVIDIA archive for cuDNN

these specific versions 上安装两个组件后,我成功获得:

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

Num GPUs Available: 1

有几条消息表明 GPU 库已正确导入。

编辑:

顺便说一句!对于那些使用 Pycharm 的人,您要么将环境变量也包括在 PyCharm 中,要么将它们设为 system-wide。否则你仍然无法让你的 TF 获得 GPU。