could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
程序员文章站
2022-05-26 23:43:39
...
训练、测试Tensorflow、Keras代码时,出现could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED、error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows、could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM等错误。
错误主要指向cudnn,但是CUDA版本和cudnn版本是符合当前tensorflow要求的,因此只能是GPU占用问题导致的。解决方法如下:
tensorflow 框架下设置GPU按需分配:
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
with tf.Session(config=config) as sess:
keras框架(Tensorflow backend) 设置GPU按需分配:
import tensorflow as tf
from keras import backend as K
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
K.set_session(sess)
Tensorflow 2.0 设置GPU按需分配方式(没有session):
gpus = tf.config.experimental.list_physical_devices('GPU')
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
上一篇: could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
下一篇: Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
推荐阅读
-
Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED的一种解决方案
-
could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
-
Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
-
Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
-
could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
-
could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
-
could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
-
Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
-
E tensorflow/stream_executor/cuda/cuda_dnn.cc:329] Could not create cudnn handle: CUDNN_STATUS_ALLOC
-
could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR