[英]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.