Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keras 3 LSTM layer's option use_cudnn=False doesn't work correctly. #20588

Open
tosa-no-onchan opened this issue Dec 4, 2024 · 2 comments
Open
Assignees
Labels

Comments

@tosa-no-onchan
Copy link

Hi Keras!
About https://keras.io/api/layers/recurrent_layers/lstm/
option
use_cudnn=False

This option doesn't work correctly on some situation.

On single use is OK.
x = layers.LSTM(128, return_sequences=True,use_cudnn=False)(x)

But on complex is not.
x = layers.Bidirectional(layers.LSTM(128, return_sequences=True,use_cudnn=False))(x)

The layers.Bidirectional() calls layers.LSTM 3 times at one operation.
use_cudnn=False <-- first call is good.
use_cudnn=Auto <-- second call is no good.
use_cudnn=Auto <-- third call is no good.

Thus, how do i resolve this problem?
I think.
An one way is to change LSTM init param in direct.

class LSTM(RNN):
    ....
    def __init__(
        ....
        #use_cudnn="auto",
        use_cudnn=False,

The other way is,I want,
to add a use_cudnn option to Model.compile option like jit_compile option.

    model.compile(
        ...
        jit_compile=False,
        use_cudnn=False,
    )

My PC
Ubuntu 22.04
Python 3.10.12
virtual env
keras 3.7.0
tensorflow 2.16.2
cuDNN v8.9.6

I am looking forward for your answer.

@mehtamansi29
Copy link
Collaborator

Hi @tosa-no-onchan -

Thanks for reporting the issue. Can you help me with sample code to reproduce this issue ?

@tosa-no-onchan
Copy link
Author

Thank you for your reply.

Sure!

My program is
https://github.com/tosa-no-onchan/opp_with_lstm

My use model is
https://github.com/tosa-no-onchan/opp_with_lstm/blob/main/model.py

Original program is
https://pylessons.com/speech-recognition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants