keras-io icon indicating copy to clipboard operation
keras-io copied to clipboard

Tensorflow Recurrent Neural Networks (RNN) with Keras colab (rnn.ipynb) Fail to find the dnn implementation. [Op:CudnnRNN]

Open dbarrau opened this issue 3 years ago • 1 comments
trafficstars

After running the colab file from the official documentation, I saw an error appearing after applying a LSTM layer on input data, only when running on either GPU offered by Google Colab.

!nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03    Driver Version: 460.32.03    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla T4            Off  | 00000000:00:04.0 Off |                    0 |
| N/A   72C    P0    32W /  70W |    468MiB / 15109MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

Import packages:

import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers

Instantiate LSTM layer:

lstm_layer = layers.LSTM(64, stateful=True)

Create input data:

paragraph1 = np.random.random((20, 10, 50)).astype(np.float32)
paragraph2 = np.random.random((20, 10, 50)).astype(np.float32)
paragraph3 = np.random.random((20, 10, 50)).astype(np.float32)

Pass paragraph1 on lstm_layer and generate the output:

output = lstm_layer(paragraph1)

Error:

---------------------------------------------------------------------------
UnknownError                              Traceback (most recent call last)
[<ipython-input-6-9442751be8e1>](https://localhost:8080/#) in <module>
      4 
      5 lstm_layer = layers.LSTM(64, stateful=True)
----> 6 output = lstm_layer(paragraph1)
      7 output = lstm_layer(paragraph2)
      8 output = lstm_layer(paragraph3)

2 frames
[/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py](https://localhost:8080/#) in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
     53     ctx.ensure_initialized()
     54     tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 55                                         inputs, attrs, num_outputs)
     56   except core._NotOkStatusException as e:
     57     if name is not None:

UnknownError: Exception encountered when calling layer "lstm_1" (type LSTM).

Fail to find the dnn implementation. [Op:CudnnRNN]

Call arguments received by layer "lstm_1" (type LSTM):
  • inputs=tf.Tensor(shape=(20, 10, 50), dtype=float32)
  • mask=None
  • training=None
  • initial_state=None

The same code runs on CPU.

dbarrau avatar Aug 18 '22 09:08 dbarrau

This bug is being reported in Google Colab issues 6 times, since the last 8 hours. https://github.com/googlecolab/colabtools/issues

dbarrau avatar Aug 18 '22 10:08 dbarrau

Hi,

Thanks for reporting the bug.

I'm able to run the example successfully in TensorFlow 2.13, could you please verify here https://gist.github.com/sachinprasadhs/5f58c80b81f4f171fe6b3dbfffb946df and close the issue. Thanks!

sachinprasadhs avatar Aug 25 '23 21:08 sachinprasadhs

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Sep 09 '23 01:09 github-actions[bot]

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

github-actions[bot] avatar Sep 23 '23 01:09 github-actions[bot]