36
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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.

Last updated at Posted at 2019-08-06

#問題
CNNで遊ぼうとしたところ、下記のエラーが発生。
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.

参考にしてと言われてもUnknown Errorとしか出てこないので対処がわからん。調べてみるとNVIDIAのGPUのうち、RTXシリーズを使用し、OSがUbuntuの場合にKerasでCNNを実行すると、例外なく発生する問題のようだ。

#環境
・ソフトウェア
Ubuntu 18.04
CUDA 10.0
cuDNN 7.6.2
tensorflow-gpu 1.14.1
Python 3.6.9
・ハードウェア
GPU:RTX 2070

#解決策
下記コードを挿入する。根本的解決にはcuDNNまわりが改善されるのを待つことしかできない模様。

import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
tf.keras.backend.set_session(tf.Session(config=config))

なお下記コードの挿入によりさらに使用するGPUを指定できる

from keras import backend as K

if 'tensorflow' == K.backend():
    import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
config.gpu_options.visible_device_list = "0"
set_session(tf.Session(config=config))

こちらを参考にした。
https://github.com/tensorflow/tensorflow/issues/24496

36
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
36
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?