利用TensorFlow进行训练时出现“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.”
-
这个网上解释的是由于cuda+cuDNN+TensorFlow版本不一致导致,但是我并不是遇到的这种情况,我使用的时TensorFlow1.14.0,按照并且装的cuda10.1,cudnn为7.6.0,但还是报此错误,关于cuda+cuDNN+TensorFlow三者的安装还是按照官方给出的资料参考。
-
关于驱动与cuda对应关系还是如下:
-
安装高版本的TensorFlow时候需要安装对应驱动。
-
降低TensorFlow版本与之匹配可能解决这个问题,我并没有试验过,不好给出绝对。因为不得已的原因我无法降低TensorFlow版本;
-
参考这个博客,在代码的开头设置:
# # 不加这几句,则CONV 报错
physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
tf.config.experimental.set_memory_growth(physical_devices[0], True)
如此程序正常运行,不会再因为cudnn未初始化而报错。
第三种针对TensorFlow小于1.14.0的方法,我试过在1.14.0版本之下会报找不到config的错误,所以方法如下:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
with tf.Session(config=config) as session:
通过设置内存分配来解决。
我叫谢琛,深度学习探索者一枚!(有意咨询xiec177)
tensorflow/pytorch交流群请加QQ:548368797
更多咨询咨询请关注!