我有一台非常强大的Windows PC(运行Windows 10),它具有112GB内存,16个内核和3个Geforce RTX2070(不支持SLI等)。它正在运行CuDNN 7.5 + Tensorflor 1.13 + Python 3.7
我的问题是,每当我尝试运行Keras模型进行训练或在矩阵上进行预测时,我都会遇到以下错误。一开始我以为只有在同时运行多个程序的情况下才会发生这种情况,但事实并非如此,现在当我仅运行单个Keras实例时,我也会遇到错误(通常-但并非总是如此)
2019-06-15 19:33:17.878911:我
tensorflow / core / common_runtime / gpu / gpu_device.cc:1115]已创建
TensorFlow设备(/ job:localhost /副本:0 /任务:0 /设备:GPU:2与
6317 MB内存)->物理GPU(设备:2,名称:GeForce RTX 2070,
pci总线ID:0000:44:00.0,计算能力:7.5)2019-06-15
19:33:23.423911:我tensorflow / stream_executor / dso_loader.cc:152]
在本地成功打开CUDA库cublas64_100.dll 2019-06-15
19:33:23.744678:E tensorflow / stream_executor / cuda / cuda_blas.cc:510]
无法创建cublas句柄:CUBLAS_STATUS_ALLOC_FAILED 2019-06-15
19:33:23.748069:E tensorflow / stream_executor / cuda / cuda_blas.cc:510]
无法创建cublas句柄:CUBLAS_STATUS_ALLOC_FAILED 2019-06-15
19:33:23.751235:E tensorflow / stream_executor / cuda / cuda_blas.cc:510]
无法创建cublas句柄:CUBLAS_STATUS_ALLOC_FAILED 2019-06-15
19:33:25.267137:E tensorflow / stream_executor / cuda / cuda_dnn.cc:334]
无法创建cudnn句柄:CUDNN_STATUS_ALLOC_FAILED 2019-06-15
19:33:25.270582:E tensorflow / stream_executor / cuda / cuda_dnn.cc:334]
无法创建cudnn句柄:CUDNN_STATUS_ALLOC_FAILED异常:
无法获得卷积算法。这可能是因为cuDNN
初始化失败,因此请尝试查看警告日志消息
印在上面。
[[{{node conv2d_1 / convolution}}]]
[[{{node density_3 / Sigmoid}}]]
最佳答案
将以下内容添加到您的代码中
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
关于python - Keras,Tensorflow,CuDDN无法初始化,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56613536/