首页 > 解决方案 > Tensorflow - 找不到 dnn [OP:CudnnRNN]

问题描述

所以当我尝试运行以下代码时,将 numpy 导入为 np

import tensorflow as tf

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

def build_model1():
    macro_data = tf.keras.Input(shape=(None, 3)) 
    
    whole_seq_output, final_memory_state, final_carry_state = layers.LSTM(16,
                                                                          dropout=.95,
                                                                          input_shape=(None,3),
                                                                          return_sequences=True, 
                                                                          return_state=True)(macro_data)   
    
    SDF_Network = tf.keras.Model(
                            inputs=[macro_data],
                            outputs=[whole_seq_output],
                            name="SDF_Network"
                            )         
    
    return SDF_Network
temp = np.array([[[1,2,3],[1,2,3]],[[1,2,3],[1,2,3]]])

SDF_Network = build_model1()
SDF_Network([temp])

我收到以下错误

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

但它只发生在 LSTM 层上,所以我认为这是一个 GPU 问题。因此,我为我的 Tensorflow 2.5 重新安装了 CUDA 11.2 和 cudnn 8.2 并设置了环境路径以及将 cudnn 文件复制到 CUDA 文件夹中,但一切仍然中断。

我还尝试像其他帖子建议的那样添加以下行

physical_devices = tf.config.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(physical_devices[0], enable=True)

仍然没有,此外我测试了 Cuda 是否正在使用

tf.test.is_built_with_cuda()
tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)

他们俩都拧真。这是我的安装过程。

#conda create --name TF-25-5 python=3.8
#conda install -c conda-forge numpy==1.19.5 
#conda install pandas
#conda install -c conda-forge matplotlib
#conda install tensorflow-gpu==2.5.0
#conda install tensorflow-datasets 
#conda install -c conda-forge tensorflow-hub
#pip install wrds
#pip install prettytables
#conda install -c conda-forge gin-config
#pip install tensorflow_addons
#pip install tensorflow-text

标签: pythontensorflow

解决方案


这是一个非常奇怪的错误。当我 pip 安装了 tensorflow-text 时,它破坏了我的 cudnn 安装。我必须 conda install cudnn 才能让它再次工作。


推荐阅读