TensorFlow2.1.0-GPU出错:Failed to get convolution algorithm
使用TF2.0或2.1。运行程序出Failed to get convolution algorithm错
运行程序出现以下错误
2020-04-06 22:36:24.284673: W tensorflow/core/common_runtime/base_collective_executor.cc:217] BaseCollectiveExecutor::StartAbort 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 small_resnet/conv2d/Conv2D}}]]
解决问题
可能是GPU内存不足造成的。需要在程序前加以下一段代码:
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession
config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)
不能正确导入(import)ConfigProto和InteractiveSession的解决过程
本人直接采用:
import tensorflow as tf
config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.compat.v1.InteractiveSession(config=config)