为啥tensorflow训练用GPU比CPU更慢了

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为啥tensorflow训练用GPU比CPU更慢了相关的知识,希望对你有一定的参考价值。

最主要的可能是GPU的利用率不足。例如我的机器跑fashion mnist,GPU利用率只有3%左右,GPU比CPU慢一倍。 参考技术A 安装GPU版本的tensorflow就可以了pipinstall--upgrade还需要安装GPU加速包,下载CUDA和cuDNN的安装包了,注意版本号分别是CUDA8.0和cuDNN5.1。
如果都安装成功,运行程序时会自动使用GPU计算本回答被提问者采纳
参考技术B 看看显存,具体参数

tensorflow 单机多GPU训练时间比单卡更慢/没有很大时间上提升

使用tensorflow model库里的cifar10 多gpu训练时,最后测试发现时间并没有减少,反而更慢

参考以下两个链接

https://github.com/keras-team/keras/issues/9204

https://medium.com/@c_61011/why-multi-gpu-training-is-not-faster-f439fe6dd6ec

原因可能是在cpu上进行参数梯度同步占每一步的很大比例

‘’‘

It seems that CPU-side data-preprocessing can be one of the reason that greatly slow down the multi-GPU training, do you try disabling some pre-processing options such as data-augmentation and then see any boost?

Besides, the current version of multi_gpu_model seems to benefit large NN-models only, such as Xception, since weights synchronization is not the bottleneck. When it is wrapped to simple model such as mnist_cnn and cifar_cnn, weights synchronization is pretty frequent and makes the whole time much slower.

 ’‘’

 

然后看到建议上提高模型复杂度(尤其是卷积层数)或者提高输入数据的大小,就可以看到多gpu训练的优势效果了

 

以上是关于为啥tensorflow训练用GPU比CPU更慢了的主要内容,如果未能解决你的问题,请参考以下文章

tensorflow 单机多GPU训练时间比单卡更慢/没有很大时间上提升

训练某些网络时,GPU 上的 Keras(Tensorflow 后端)比 CPU 上慢

tensorflow能不能gpu cpu 一起训练

在 GPU 上训练比在 CPU 上慢得多 - 为啥以及如何加快速度?

PyTorch:用 GPU 训练比用 CPU 训练同样的东西错误更严重

TensorFlow指定GPU/CPU进行训练和输出devices信息