我正在使用GPU进行训练吗?

3
我将使用keras和tensorflow作为后端来训练神经模型。日志文件以以下消息开始:
nohup: ignoring input
2019-02-12 17:44:29.414526: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
2019-02-12 17:44:30.191565: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties: 
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7335
pciBusID: 0000:65:00.0
totalMemory: 7.93GiB freeMemory: 7.81GiB
2019-02-12 17:44:30.191601: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0
2019-02-12 17:44:30.409790: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-02-12 17:44:30.409828: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971]      0 
2019-02-12 17:44:30.409834: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0:   N 
2019-02-12 17:44:30.410015: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7535 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:65:00.0, compute capability: 6.1)

这是否意味着训练是在GPU上执行的?

我会说是的,但是当我执行nvtop时,我看到所有的GPU内存都被使用,而GPU计算能力的使用率为0%(请参见下面的黄色屏幕截图):

see screenshot

此外,当我在命令行中输入htop时,可以看到一个CPU被完全使用(请参见下方黑色截图)。

see screenshot

为什么会使用GPU内存和CPU计算能力,而不是GPU计算能力?

除了日志记录/打印/调试之外,您还可以使用tf.device指令来强制操作在GPU上运行,因此如果由于某些原因无法使用GPU,则会失败(请注意,某些操作,例如大多数数据输入,不能在GPU上运行,因此请将其用于“纯计算”)。也可能是您的输入管道花费了很多时间,因此GPU没有被快速地提供足够的数据,请参见数据输入管道性能 - jdehesa
@bluesummers 我认为训练开始了,因为我有通常的进度条 249/508100 [..............................] - ETA: 31:12:33 - loss: 0.5588 - dada
看不出问题在哪里,我会做的最后一件事就是将您的批处理大小增加100倍,看看是否有任何变化。可能数据太小了,您实际上没有使用nvtop所需的容量。 - bluesummers
@bluesummers,不幸的是,这并没有改变太多。我将批量大小从32更改为512。 - dada
你应该在你的问题中包含实际的代码。 - Dr. Snoopy
显示剩余5条评论
1个回答

0

我认为你已经编译了(或者安装了已经带 CUDA 支持的包)tensorflow,但是没有支持你的 CPU 的所有指令(你的 CPU 支持 AVX2、AVX512F 和 FMA 指令,这些指令都可以被 tensorflow 使用)。

这意味着,tensorflow 将正常工作(具有完全的 GPU 支持),但不能充分利用你的处理器。

尝试使用此示例比较时间(GPU vs CPU):https://stackoverflow.com/a/54661896/10418812


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接