DeepSpeech icon indicating copy to clipboard operation
DeepSpeech copied to clipboard

cuDNN LSTM cells

Open kjanko opened this issue 9 years ago • 10 comments

Would it be possible to use the CuDNNLSTM cells implemented by Tensorflow (https://www.tensorflow.org/api_docs/python/tf/contrib/cudnn_rnn/CudnnLSTM) in order to gain on performance?

In the current implementation of the deep speech model, BasicLSTMCell are being used - in comparison, according to the nvidia study, the optimized CuDNN LSTM should be ~6x faster.

kjanko avatar Oct 13 '17 13:10 kjanko

Interesting!

When we initially set up the system CudnnLSTM didn't exist. So we simply used BasicLSTMCell.

If the 6x factor is true. It would be a huge win.

kdavis-mozilla avatar Oct 13 '17 14:10 kdavis-mozilla

On the issue regarding non-cuda systems: https://github.com/tensorflow/tensorflow/issues/6072

kjanko avatar Oct 14 '17 17:10 kjanko

TensorFlow 1.4 (current version required and also used by Mozilla's fork) does not play well with CudnnLSTM cells and the documentation is terrible, although I can confirm the 6X speedup based on some simple initial benchmarks.

It is reasonably straight forward to get the checkpoints to save the CudnnLSTM weights and biases in the TensorFlow format, rather than an opaque one. However, using an optimizer other than SGD results in:

https://github.com/tensorflow/tensorflow/issues/6620

which is...less straight forward.

Note that the CudnnLSTM API has also significantly changed in TensorFlow version 1.5.

samgd avatar Jan 31 '18 17:01 samgd

@kdavis-mozilla, is there any timeline for this ? 6X speedup will be really amazing !!

praveeny1986 avatar Feb 08 '18 09:02 praveeny1986

@praveeny1986 No timeline so far, but we are having a "work week" next week; so, the team can talk about it in person there.

kdavis-mozilla avatar Feb 09 '18 09:02 kdavis-mozilla

This issue is blocked by https://github.com/tensorflow/tensorflow/issues/23269

reuben avatar Jan 29 '19 17:01 reuben

TF 1.14 (and, currently, nightly) now have support for variable sequence lengths in cudnn_rnn. I'm running some preliminary experiments to benchmark it, on top of the TF 1.13/tf.data changes.

Runs using 7 GPUs, with another unrelated TTS job using the 8th GPU:

without CuDNN with CuDNN speedup
Time for 1st epoch 10h24min (37487 seconds) 6h58min (25120 seconds) 1.5x
Time for other epochs 2h (7200 seconds) 2h30min (9000 seconds) 0.8x

I think the resource competition on the machine makes these results hard to evaluate, so I'll do some runs using all 8 GPUs taking the whole node in the future.

reuben avatar Mar 18 '19 21:03 reuben

TF 1.14.0-rc0 is out. Self-reminder to do some experiments using it rather than TF-Nightly-GPU.

reuben avatar May 29 '19 13:05 reuben

This was implemented and merged a while ago.

reuben avatar Oct 31 '19 14:10 reuben

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Nov 30 '19 14:11 lock[bot]