failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED 错误解决方法

解决:

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)

还有这样的(固定分配):

gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))

记得关闭其他用显存的程序哦!。。。

第二个:

训练、测试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等错误。将下段代码加入其中即可。

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)
原文地址:https://www.cnblogs.com/gaofighting/p/11059752.html