tensorflow2.x版本,cudn和cudnn对应版本已经装好并成功调用了,但是代码还是报错::“无法获取卷积算法,这可能是因为cuDNN初始化失败”
报错内容:
tensorflow.python.framework.errors_impl.UnknownError: 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.
报错原因:
cuDNN初始化失败,这是由于无法获取卷积算法造成的
解决方法:
复制以下3行代码到程序的开始即可:
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)
如果文章解决您多年未解之谜,请一键三连!