【问题标题】:Why does adding convolution/pool layer crash Keras/Tensorflow model while running on RTX 3070/cudnn8/CUDA11.1?为什么在 RTX 3070/cudnn8/CUDA11.1 上运行时添加卷积/池层会使 Keras/Tensorflow 模型崩溃?
【发布时间】:2020-12-09 22:04:40
【问题描述】:

系统信息

  • 操作系统:Windows 10,
  • cudnn:8.0,
  • CUDA 工具包:11.1 安装在 10.2 之上,
  • GPU:Nvidia RTX 3070,
  • CPU:英特尔 I7 10700f,
  • Tensorflow:tf.__version__==2.4.0rc-0(也曾在 2020 年 12 月 7 日尝试使用 tf-nightly-gpu
  • CUDA、cudnn 从源代码手动编译

测试代码

以下代码成功编译模型,但在调用model.fit(...) 时崩溃。


from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt

(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()

train_images, test_images = train_images / 255.0, test_images / 255.0

model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10))

model.compile(optimizer='Adam', loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True))

history = model.fit(train_images, train_labels, batch_size=10, epochs=100)

通过移除 convolutionalma​​xpooling 层并在输入后将张量展平,模型能够很好地训练(显然这个模型的输出是无用的,但它是仍然可以训练)。

程序崩溃时的错误代码是>Process finished with exit code -1073740791 (0xC0000409)

此外,tensorflow 能够在调用tf.config.list_physical_devices('GPU') 时打开库、查找 GPU 并将 GPU 记录为可用

更新 我在 tensorflow github 页面上打开了一个问题,你可以找到 here

【问题讨论】:

  • 这可能是一个错误,您知道 rc 表示候选发布版本,并且夜间构建不稳定吗?与其在这里提问,不如向 TensorFlow(在 github 中)报告一个错误,以便在最终 2.5 版本发布之前修复它。你也试过2.4版吗? (非 rc 之一)
  • rc=发布候选;是的,每晚=不稳定;是的。问题是最新的稳定版本(2.3.1)不支持安培架构(存在于 3000 系列 GPU 上),我将在 github 上报告这个问题,我只是想我也会在这里问,因为我'见过有人在 3000 系列 GPU 上成功运行 CNN,但大多数人使用的是 linux 发行版
  • 不幸的是,Linux 是大多数深度学习框架中的一等公民,而 Windows 则被视为二等公民,也许这是 Windows 特定的错误,我也会尝试最新版本(甚至是 rc)。
  • 感谢@Dr.Snoopy,我会试一试,看看是否会弹出任何新信息!

标签: python tensorflow keras gpu


【解决方案1】:

无论出于何种原因,当在 IDE 终端中运行时,一条错误消息被抑制,Process finished with exit code -1073740791 (0xC0000409) 被记录为错误消息。

从命令行运行时,会显示以下错误消息,而不是记录退出代码错误。

Could not load library cudnn_ops_infer64_8.dll. Error code 126
Please make sure cudnn_ops_infer64_8.dll is in your library path!

我识别出这是包含在cudnn库中的一个包,并将其从cudnn的bin文件夹中复制并粘贴到NVIDIA GPU计算工具包> CUDA > V11.0 > bin。对以下软件包重复此过程,问题已解决。

cudnn_adv_infer64_8.dll
cudnn_adv_train64_8.dll
cudnn_cnn_infer64_8.dll
cudnn_cnn_train64_8.dll
cudnn_ops_infer64_8.dll
cudnn_ops_train64_8.dll

【讨论】:

  • 我已经将这些文件粘贴到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin,但仍然出现同样的错误
  • 该文件夹是否已添加到您的环境变量中?
猜你喜欢
  • 2023-03-08
  • 1970-01-01
  • 2020-09-07
  • 2023-03-12
  • 1970-01-01
  • 1970-01-01
  • 2019-05-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多