繁体   English   中英

Keras 使用 LSTM 网络在 GPU 上慢

[英]Keras slow on GPU with LSTM Networks

我正在用 keras 训练我的 model。 当我比较 GPU 与 CPU 的性能时。 CPU版本比GPU版本快很多

我如何在下面修复这些错误?

我试图强制 tensorflow 到 GPU,我得到这些错误:

tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device to node 'gradients/simple_rnn_1/while/Select_1_grad/Select/f_acc': 
Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available. 
Colocation Debug Info: 
Colocation group had the following types and devices: 
Tile: CPU 
StackPush: GPU CPU 
Relu: GPU CPU 
ReluGrad: GPU CPU 
ZerosLike: GPU CPU 
Select: GPU CPU 
StackPop: GPU CPU 
AddN: GPU CPU 
RefEnter: GPU CPU 
Stack: GPU CPU

我的 Model 看起来像这样:

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
masking_1 (Masking)          (None, None, 3)           0         
_________________________________________________________________
simple_rnn_1 (SimpleRNN)     (None, None, 50)          2700      
_________________________________________________________________
time_distributed_1 (TimeDist (None, None, 11)          561       
_________________________________________________________________
activation_1 (Activation)    (None, None, 11)          0         
=================================================================
Total params: 3,261
Trainable params: 3,261 

编辑:当我将后端切换到 theano 时,相同的网络在 GPU 上运行得更快,我认为 tensorflow 中 GPU 上的“平铺”存在问题

如果您使用 ReLU,请尝试使用Tanh损失。

我在 100 个时期将 ReLU 用于 LSTM-DNN model。 每个 Epoch 从大约 14 秒变为 2

希望这可以解决您的问题-我也在 GPU 上运行,所以不幸的是它可能只是您的处理器-如果您遇到瓶颈,请使用谷歌 Colab-您可以免费使用 GPU

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM