问题解决:Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED

tensorflow2.0版本
错误和cudnn有关,排除了cuda和cudnn的版本问题,在网上查了一下,应该是GPU被占用,所以无法使用,需要在代码里面添加几行语句,设置GPU的按需分配

添加代码

import tensorflow as tf
physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0
tf.config.experimental.set_memory_growth(physical_devices[0], True)
assert tf.config.experimental.get_memory_growth(physical_devices[0]) == True

原文链接:https://blog.csdn.net/He110__W0r1d/article/details/102961611

发布了23 篇原创文章 · 获赞 1 · 访问量 357

猜你喜欢

转载自blog.csdn.net/weixin_46276803/article/details/104495121
今日推荐