解决 cuDNN launch failure 错误

在神经网络模型推断过程中,报错Internal: cuDNN launch failure : input shape ([1,3,2048,2048]) node bn_data/FusedBatchNorm ,本文记录解决方案。

原因分析

网上有怀疑该问题由BN层引起,去掉BN层可以解决问题TensorFlow实战 InternalError: cuDNN launch failure : input shape(未解决求交流)

更换cudnn版本也无济于事。

事实上更可能是TensorFlow显存配置的问题(事实上也是缺少证据的,只是按照这个思路可以排除故障,因此该因素应该是最大似然的原因)

解决方案

在代码中加入按需分配显存的配置:

方案1

 con = tf.ConfigProto()
 con.gpu_options.allow_growth = True
 keras.backend.tensorflow_backend.set_session(tf.Session(config=con)) 
复制代码

方案2

os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'
复制代码

原理相同,只是不一样的写法。

猜你喜欢

转载自juejin.im/post/7018057487836250149