无法在 TensorFlow 中使用 GPU 进行训练

Cant train with GPU in TensorFlow

我正在研究 CNN,我注意到在训练阶段它使用 CPU 100% 而不是 GPU(我有 GTX 1660Ti)。

Tensorflow 无法识别我的 1660Ti

我尝试从 TensorFlow 网站关注 this guide

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

产出

Num GPUs Available:  0

我尝试读取 TensorFlow 识别的所有设备

tf.config.list_physical_devices()

产出

[ PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU') ]

我阅读了关于该主题的内容

在互联网上搜索我发现也许我必须安装 NVidia CUDA 工具包。我是从here开始做的,没解决

我发现 NVidia CUDA 并不总是在所有 GPU 上启用:source。我觉得有点奇怪,为什么NVidia要切断一部分客户使用CUDA?

附加信息

我的requirements.txt(如果软件版本可以帮助解决我的问题):

matplotlib==3.4.2
keras==2.4.3
tensorflow-gpu==2.5.0
seaborn==0.11.1

我是 运行 python Jupyter Notebook 中的代码(通过 pip 安装)

我的问题

有一种方法可以将我的 GPU 用于 CUDA(或者至少使用 TensorFlow,就像在这种情况下一样)?

我终于解决了

我不得不从 here, and following this 安装指南下载 cuDNN 我终于让它工作了。

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

现在输出

Num GPUs Available:  1

tf.config.list_physical_devices()

现在输出

[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'),