TensorFlow教程

Tensorflow调试经验---“Failed to get convolution algorithm. This is probably because cuDNN failed to ini”

本文主要是介绍Tensorflow调试经验---“Failed to get convolution algorithm. This is probably because cuDNN failed to ini”,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

今天使用tensorflow2.0出现faile,我笔记本是Y7000p,显卡是2060显存就有6G所以在使用的时候出现问题:

Failed to get convolution algorithm. This is probably because cuDNN failed to initialize

解决方案:

#tensorflow1.X版本
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession

#方法一:限制GPU使用率
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.85  #占用85%显存
session = tf.Session(config=config)

#方法二:对GPU按需分配
config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)

使用keras出现这个报错的时候可以:

import tensorflow as tf
import keras 
config = tf.compat.v1.ConfigProto(allow_soft_placement=True)
 
config.gpu_options.per_process_gpu_memory_fraction = 0.3
tf.compat.v1.keras.backend.set_session(tf.compat.v1.Session(config=config))
这篇关于Tensorflow调试经验---“Failed to get convolution algorithm. This is probably because cuDNN failed to ini”的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!