python - 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
解决方案
这是一个非常奇怪的错误。当我 pip 安装了 tensorflow-text 时,它破坏了我的 cudnn 安装。我必须 conda install cudnn 才能让它再次工作。
推荐阅读
- azure - 身份服务器 4 联合注销:当我从身份提供者注销时,我想从我的应用程序中注销
- git - 如何检查 bash 脚本内的 GitHub 存储库中的最新文件是什么?
- java - 删除二叉搜索树中的节点
- arrays - 如何获取数组对象以获取值
- python - 使用 Selenium 和 Python 的 Whatsapp 自动化错误
- javascript - JavaScript:使用 alert 关键字和 return 关键字
- python - 如何解决 h5py 安装 keras 的问题?
- python - 使用 move() 方法后矩形对象不可见:Canvas-Tkinter
- c# - 如何将函数绑定到进度条?
- c# - 在 AuthorizationHandler 中使用 `await`