簡體   English   中英

Keras、Tensorflow、CuDDN 初始化失敗

[英]Keras, Tensorflow, CuDDN fails to initialize

我有一台非常強大的 Windows PC(運行 Windows 10),它有 112GB 內存、16 個內核和 3 X 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/replica:0/task:0/device:GPU:2 with 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 句柄:CUALLOCLAS_100F19-19:33:23.744678 :33:23.748069: E tensorflow/stream_executor/cuda/cuda_blas.cc:510] 未能創建 cublas 句柄: CUBLAS_STATUS_ALLOC_FAILED 2019-06-15 19:33:23.751235/stream.executorcuda_executor5] 未能創建 cublas創建 cublas 句柄:CUBLAS_STATUS_ALLOC_FAILED 2019-06-15 19:33:25.267137: E tensorflow/stream_executor/cuda/cuda_dnn.cc:334] 無法創建 cudnn 句柄:CUBLAS_STATUS_207135:E tensorflow/stream_executor/cuda/cuda_dnn.cc:334: E tensorflow/stream_executor/cuda/cuda_dnn.cc:334] nsorflow/stream_executor/cuda/cuda_dnn.cc:334] 無法創建 cudnn 句柄:CUDNN_STATUS_ALLOC_FAILED 異常:無法獲得卷積算法。 這可能是因為 cuDNN 初始化失敗,所以嘗試查看上面是否打印了警告日志消息。 [[{{node conv2d_1/convolution}}]] [[{{nodedense_3/Sigmoid}}]]

在 Tensorflow 2.0 及更高版本上,您可以通過以下方式解決此問題:

os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'

或者

physical_devices = tf.config.experimental.list_physical_devices('GPU')
if len(physical_devices) > 0:
    tf.config.experimental.set_memory_growth(physical_devices[0], True)

將以下內容添加到您的代碼中

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM