Home

Awesome

rnn-benchmarks

All benchmarks are reported for a host with the following specifications :

These benchmarks compare the running time of various recurrent neural networks on different deep-learning libraries. The networks (RNN or LSTM) take as input a 3D Tensor batch_size x seq_length x hidden_size and output the last hidden state, compute a MSE loss, backpropagate the errors through the network and do a simple update of the parameters (params = params - lr*gradParams). The sequence length is always set to 30. The hidden_size specifies the size of the output and input layer of the networks.

The code of the scripts we ran are available. The implementations of each model on the different libraries each use the fastest implementations we were able to find. If you are aware of faster implementations, please let me know. I've reported results on Theano, Torch and TensorFlow so far, but we will try to include many more libraries in the future (including cudnn very soon).

The reported Train time is the average time needed to run (forward, backward, and update) a training example (and not a training batch), so the smaller the better. We also report Compile time, which includes symbolic graph optimizations (Theano and TensorFlow compilation), as well as a forward and backward pass (to allocate memory). While the compilation time isn't really a factor in production, it does increase debugging time, which is why we report it here.

LSTM

This LSTM implementation used for these benchmarks does not use peephole connections between cell and gates.

Batch Size 32

Hidden Size 128

LibraryCompile (s)Train (µs)Forward only (µs)
Theano7.46289.699.1
Torch0.03434.499.9
TensorFlow3.91820.0266.7

Hidden Size 512

LibraryCompile (s)Train (µs)Forward only (µs)
Theano7.59619.4200.9
Torch0.19610.7201.7
TensorFlow3.97886.9324.9

Hidden Size 1024

LibraryCompile (s)Train (µs)Forward only (µs)
Theano9.621013.5324.1
Torch0.691139.8346.3
TensorFlow3.811329.2562.7

Batch Size 128

Hidden Size 128

LibraryCompile (s)Train (µs)Forward only (µs)
Theano7.38102.925.6
Torch0.03109.825.2
TensorFlow3.68188.665.0

Hidden Size 512

LibraryCompile (s)Train (µs)Forward only (µs)
Theano7.50256.062.8
Torch0.20214.351.4
TensorFlow3.73255.2114.2

Hidden Size 1024

LibraryCompile (s)Train (µs)Forward only (µs)
Theano7.45583.4160.2
Torch0.75558.1112.4
TensorFlow3.84592.2238.1

RNN

This section benchmarks a simple RNN implementation.

Batch Size 32

Hidden Size 128

LibraryCompile (s)Train (µs)Forward only (µs)
Theano4.31104.630.9
Torch0.05259.53103.06
TensorFlow1.64278.4111.5

Hidden Size 512

LibraryCompile (s)Train (µs)Forward only (µs)
Theano4.36275.2102.2
Torch0.05288.2114.6
TensorFlow1.62349.7218.4

Hidden Size 1024

LibraryCompile (s)Train (µs)Forward only (µs)
Theano4.44443.8179.5
Torch0.09381.4118.8
TensorFlow1.72530.0241.7

Batch Size 128

Hidden Size 128

LibraryCompile (s)Train (µs)Forward only (µs)
Theano4.4845.413.7
Torch0.0867.732.7
TensorFlow1.7075.533.6

Hidden Size 512

LibraryCompile (s)Train (µs)Forward only (µs)
Theano4.4079.023.8
Torch0.0973.534.2
TensorFlow1.63125.686.8

Hidden Size 1024

LibraryCompile (s)Train (µs)Forward only (µs)
Theano4.38147.850.3
Torch0.13150.264.7
TensorFlow1.70222.5137.8