[英]Keras slow on GPU with LSTM Networks
I am training my model with keras.我正在用 keras 训练我的 model。 When I compare the performance on GPU vs CPU.当我比较 GPU 与 CPU 的性能时。 The CPU version is much faster as the GPU version CPU版本比GPU版本快很多
How i can fix these errors below?我如何在下面修复这些错误?
I tried to force tensorflow to the GPU, i get these errors:我试图强制 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
My Model looks like this:我的 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
EDIT: When i switch the backend to theano, the same net runs much faster on the GPU, i think there is a problem with "tile" on GPU in tensorflow编辑:当我将后端切换到 theano 时,相同的网络在 GPU 上运行得更快,我认为 tensorflow 中 GPU 上的“平铺”存在问题
If you are using ReLU, try use a Tanh loss.如果您使用 ReLU,请尝试使用Tanh损失。
I was using ReLU for a LSTM-DNN model at 100 epochs.我在 100 个时期将 ReLU 用于 LSTM-DNN model。 Each Epoch went from about 14 second to 2每个 Epoch 从大约 14 秒变为 2
hopefully this solves your problem - I was running on GPU too so it could just be your processor unfortunately - use google Colab if you are bottlenecked - you get access to free GPU usage希望这可以解决您的问题-我也在 GPU 上运行,所以不幸的是它可能只是您的处理器-如果您遇到瓶颈,请使用谷歌 Colab-您可以免费使用 GPU
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.