keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.06k stars 19.35k forks source link

LSTM layer with dropout does not use fast CuDNN implementation in Keras 3 #19644

Closed giulatona closed 2 weeks ago

giulatona commented 2 weeks ago

I have a model that uses the keras LSTM layer with dropout not equal to zero. I am using TF backend.

I noticed a performance drop after updating to Keras 3 and after checking I found out that the requirements for using the fast CuDNN LSTM implementation.

With Keras 2.15, the requirements to use the cuDNN implementation are:

  1. activation == tanh
  2. recurrent_activation == sigmoid
  3. recurrent_dropout == 0
  4. unroll is False
  5. use_bias is True
  6. Inputs, if use masking, are strictly right-padded.
  7. Eager execution is enabled in the outermost context.

With Keras 3, the requirements to use the cuDNN implementation are:

  1. activation == tanh
  2. recurrent_activation == sigmoid
  3. dropout == 0 and recurrent_dropout == 0
  4. unroll is False
  5. use_bias is True
  6. Inputs, if use masking, are strictly right-padded.
  7. Eager execution is enabled in the outermost context.

This change has a significant impact on performance when using dropout. Can we expect a change or some alternative way to use dropout without performance degradation?

fchollet commented 2 weeks ago

Thanks for the report -- this is now resolved at HEAD.