在跟着视频写代码时,一个很小的卷积test竟然出现如下错误:
这个问题困扰了我将近两天,查阅了各种网页,尝试了各种方法,建议首先打开任务管理器,查看在运行代码的时候,GPU的占用情况如何,发现果然是我的GPU内存不足了,那么这个时候,就应该搜索tensorflow2.0 gpu out of memory如何处理:
法一:加上这两句话,但之后的运行时好时坏
physical_device = tf.config.experimental.list_physical_devices("GPU") tf.config.experimental.set_memory_growth(physical_device[0], True)
法二:加上这几句话,意思大概也是运行内存增加
physical_devices = tf.config.experimental.list_physical_devices('GPU') if len(physical_devices) > 0: for k in range(len(physical_devices)): tf.config.experimental.set_memory_growth(physical_devices[k], True) print('memory growth:', tf.config.experimental.get_memory_growth(physical_devices[k])) else: print("Not enough GPU hardware devices available")
踩过的坑:以为是cuda和cudnn之间不匹配的关系,如果是的话,可以参考这篇文章:(13条消息) tensorflow-gpu2.0报错:Failed to get convolution algorithm. This is probably because cuDNN..._Raver & Leaper的博客-CSDN博客
继续探索中。。。