[DL]運行Keras時遇到CUDNN_STATUS_INTERNAL_ERROR問題

Posted by John on 2020-01-01
Words 232 and Reading Time 1 Minutes
Viewed Times

問題描述

最近在執行Keras程式碼時,遇到了以下的問題:

UnknownError: 2 root error(s) found.
(0) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
[[{ {node conv2d_3/convolution}}]]
[[loss_1/mul/_201]]
(1) Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
[[{ {node conv2d_3/convolution}}]]
0 successful operations.
0 derived errors ignored.

環境描述

  • 當前的tensorflow版本: 1.14.0
  • 當前的keras版本: 2.2.4
  • 當前的cuda版本: cuda 10

解決辦法

一開始以為是cuda版本或是gpu驅動不相容的問題,不過後來研究了一下找到了solution,不用重裝cuda和驅動就可以解決,解法是參照github的issue加入這段code:

1
2
3
4
5
6
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession

config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)

之後就可以正常執行Keras。


>