无法在TensorFlow中使用GPU进行训练 [英] Cant train with GPU in TensorFlow

查看:29
本文介绍了无法在TensorFlow中使用GPU进行训练的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做CNN,我注意到在培训阶段它100%使用CPU,而不是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') ]
我在主题上读到的内容

在Internet中搜索,我发现可能需要安装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笔记本(通过pip安装)中运行python代码

我的问题

有办法将我的GPU用于CUDA(或者至少像本例一样使用TensorFlow)吗?

推荐答案

我终于解决了。

我必须从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'),

这篇关于无法在TensorFlow中使用GPU进行训练的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆