首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Keras,Tensorflow,CuDDN无法初始化

Keras,Tensorflow,CuDDN无法初始化
EN

Stack Overflow用户
提问于 2019-06-15 19:24:17
回答 2查看 3.5K关注 0票数 4

我有一个非常强大的Windows (运行Windows 10),它有112 16内存,16核和3 X Geforce RTX2070 (不支持SLI等)。它正在运行CuDNN 7.5 + Tensorflor 1.13 +Python3.7

我的问题是,每当我尝试运行Keras模型进行训练或对矩阵进行预测时,我都会得到下面的错误。一开始,我认为只有同时运行更多的程序才会发生这种情况,但情况并非如此,现在我只运行一个Keras实例时也会出现错误(通常--但并不总是这样)。

2019-06-15 19:33:17.878911: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115]创建了TensorFlow设备(/job:localhost/TensorFlow:0/TensorFlow:0/ device : GPU :2和6317 MB内存) ->物理GPU(设备: 2,名称: GeForce RTX 2070,pci总线id: 0000:44:00.0,计算能力: 7.5) 2019-06-15 19:23.423911:I tensorflow/stream_executor/dso_loader.cc:152]成功地在本地打开CUDA库cublas64_100.dll 2019-06-15 19:33:23.744678: e cublas64_100.dll未能创建cublas句柄: CUBLAS_STATUS_ALLOC_FAILED 2019-06-15 19:33:23.748069: e tensorflow/stream_executor/cuda/cuda_blas.cc创建cublas句柄失败: tensorflow/stream_executor/cuda/cuda_blas.cc:510] 2019-06-15 19:33:23.751235: e tensorflow/stream_executor/cuda/cuda_dnn.cc:334]未能创建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 :33:25.270582E tensorflow/stream_executor/cuda/cuda_dnn.cc:334]无法创建cudnn句柄: CUDNN_STATUS_ALLOC_FAILED异常:未能得到卷积算法。这可能是因为cuDNN未能初始化,所以尝试查看上面是否打印了警告日志消息。[{节点卷积}][{节点密度3/Sigmoid}}]

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-06-15 19:43:57

将以下内容添加到代码中

代码语言:javascript
复制
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
票数 1
EN

Stack Overflow用户

发布于 2020-02-26 16:22:45

在Tensorflow 2.0和更高版本上,您可以这样解决这个问题:

代码语言:javascript
复制
os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'

代码语言:javascript
复制
physical_devices = tf.config.experimental.list_physical_devices('GPU')
if len(physical_devices) > 0:
    tf.config.experimental.set_memory_growth(physical_devices[0], True)
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56613536

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档