Tensorflow 2.0中是否有cudnnLSTM或cudNNGRU替代品 [英] Is there cudnnLSTM or cudNNGRU alternative in tensorflow 2.0
问题描述
TensorFlow 1.0
中的CuDNNGRU
确实非常快.但是当我转到TensorFlow 2.0
时,我找不到CuDNNGRU
.简单的GRU
在TensorFlow 2.0
中真的很慢.
The CuDNNGRU
in TensorFlow 1.0
is really fast. But when I shifted to TensorFlow 2.0
i am unable to find CuDNNGRU
. Simple GRU
is really slow in TensorFlow 2.0
.
有什么方法可以在TensorFlow 2.0
中使用CuDNNGRU
?
Is there any way to use CuDNNGRU
in TensorFlow 2.0
?
推荐答案
The importable implementations have been deprecated - instead, LSTM
and GRU
will default to CuDNNLSTM
and CuDNNGRU
if all conditions are met:
-
activation = 'tanh'
-
recurrent_activation = 'sigmoid'
-
recurrent_dropout = 0
-
unroll = False
-
use_bias = True
- 输入如果被屏蔽,请严格右击
-
reset_after = True
(仅限GRU)
activation = 'tanh'
recurrent_activation = 'sigmoid'
recurrent_dropout = 0
unroll = False
use_bias = True
- Inputs, if masked, are strictly right-padded
reset_after = True
(GRU only)
还要确保TensorFlow使用GPU:
Also ensure TensorFlow uses GPU:
import tensorflow as tf
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
更新:在Colab上运行时,似乎在TF 2.0.0上存在问题,以使CuDNN正常工作;尝试使用!pip install tensorflow==2.1.0
.
Update: there appears to be a problem w/ TF 2.0.0 when running on Colab in getting CuDNN to work; try !pip install tensorflow==2.1.0
instead.
这篇关于Tensorflow 2.0中是否有cudnnLSTM或cudNNGRU替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!