Keras深度学习时报错 failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
需要添加一下代码到文件中:
from keras.backend.tensorflow_backend import set_session
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True # dynamically grow the memory used on the GPU
config.log_device_placement = True # to log device placement (on which device the operation ran)
sess = tf.Session(config=config)
set_session(sess) # set this TensorFlow session as the default session for Keras
本文解决了一个常见的Keras深度学习框架在使用GPU时遇到的问题:内存分配失败。通过动态调整GPU内存使用,避免了CUBLAS_STATUS_ALLOC_FAILED错误。文中详细介绍了如何在代码中设置TensorFlow会话,确保GPU资源被合理利用。


被折叠的 条评论
为什么被折叠?



