E tensorflow/stream_executor/cuda/cuda_dnn.cc:334] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
如标题所示,最近博主写代码的时候tensorflow报错Could not create cudnn handle。
这可能是因为你的gpu分配出现了问题,所以我们设置config,让gpu能够正常使用。如果你在使用tensorflow 1.x的版本,请在主程序运行前添加以下代码:
import tensorflow as tf
from tensorflow.compat.v1 import InteractiveSession
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)
如果你使用的是tensorflow 2.x版本,请添加以下代码:
import tensorflow as tf
from tensorflow.compat.v1 import InteractiveSession
config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)
希望能够解决你的问题,祝好