“Failed to get convolution algorithm. This is probably because cuDNN failed to initialize”错误的解决办法

  • 最近在使用TF2.0,运行程序时出现以下错误:
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. [Op:Conv2D]
  • 一开始怀疑是CUDA和CuDNN配置错误。反复试验后发现可能是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)
  • 意思是对GPU进行按需分配。主要原因是训练图像较大,消耗GPU资源较多。但我的RTX2060显存只有6GB,所以会出现这个错误。

你可能感兴趣的:(“Failed to get convolution algorithm. This is probably because cuDNN failed to initialize”错误的解决办法)