我正在研究 CNN,我注意到在训练阶段它使用 CPU 100% 而不是 GPU(我有一个 GTX 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
我在 Jupyter Notebook(通过 pip 安装)中运行 python 代码
有没有办法将我的 GPU 用于 CUDA(或者至少使用 TensorFlow,就像在这种情况下一样)?
答案 0 :(得分:0)
我终于解决了。
我必须从 here 下载 cuDNN,并且按照 this 安装指南我终于让它工作了。
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'),
PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]