我在开发一个卷积神经网络时注意到,训练阶段使用的是CPU,CPU使用率达到100%,而没有使用我的GTX 1660Ti显卡。
TensorFlow无法识别我的1660Ti
我尝试按照TensorFlow网站上的这个指南进行操作。
import tensorflow as tfprint("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工具包。我从这里进行了安装,但问题依然存在。
我发现NVidia CUDA并非在所有GPU上都启用:来源。我觉得这有点奇怪,为什么NVidia要限制部分客户使用CUDA?
附加信息
我的requirements.txt文件(如果软件版本有助于解决问题):
matplotlib==3.4.2keras==2.4.3tensorflow-gpu==2.5.0seaborn==0.11.1
我在Jupyter Notebook中运行Python代码(通过pip安装)
我的问题
有没有办法让我使用GPU进行CUDA计算(或者至少像这种情况一样使用TensorFlow)?
回答:
我最终解决了这个问题。
我从这里下载了cuDNN,并按照这个安装指南,最终使其正常工作。
import tensorflow as tfprint("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'),