在TensorFlow中使用GPU进行超高训练

2024-05-29 06:53:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我在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') ]

我在这个主题上读到了什么

在互联网上搜索时,我发现可能我必须安装NVidia CUDA toolkit。我是从here开始做的,但没有解决它

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

其他信息

Myrequirements.txt(如果软件版本有助于解决我的问题):

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

我正在Jupyter笔记本中运行python代码(通过pip安装)

我的问题

有一种方法可以将我的GPU用于CUDA(或者至少使用TensorFlow,如本例所示)


Tags: configgpudevicetftensorflowcpunumcuda
1条回答
网友
1楼 · 发布于 2024-05-29 06:53:07

我终于解决了

我不得不从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(名称='/physical_设备:GPU:0',设备_类型='GPU')]

相关问题 更多 >

    热门问题