解决报错:tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm.

早上在使用tensorflow时报了下面的错:

2019-04-10 10:19:31.648250: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2019-04-10 10:19:31.892490: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:
name: GeForce GTX 960M major: 5 minor: 0 memoryClockRate(GHz): 1.176
pciBusID: 0000:01:00.0
totalMemory: 4.00GiB freeMemory: 3.34GiB
2019-04-10 10:19:31.905680: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
2019-04-10 10:19:34.257692: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-04-10 10:19:34.265965: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0
2019-04-10 10:19:34.270962: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N
2019-04-10 10:19:34.276521: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3050 MB memory) -> physical GPU (device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0, compute capability: 5.0)
2019-04-10 10:19:35.706884: I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library cublas64_100.dll locally
2019-04-10 10:19:36.098589: E tensorflow/stream_executor/cuda/cuda_blas.cc:510] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
2019-04-10 10:19:36.125748: E tensorflow/stream_executor/cuda/cuda_blas.cc:510] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
2019-04-10 10:19:36.132951: E tensorflow/stream_executor/cuda/cuda_blas.cc:510] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
2019-04-10 10:19:37.181460: E tensorflow/stream_executor/cuda/cuda_dnn.cc:334] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
2019-04-10 10:19:38.085867: E tensorflow/stream_executor/cuda/cuda_dnn.cc:334] Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
Traceback (most recent call last):
  File ".\my-hyp.py", line 322, in <module>
    best_run=cnn_model(x_train, x_test, y_train, y_test, max_features, maxlen)
  File ".\my-hyp.py", line 294, in cnn_model
    verbose=1)
  File "C:\Users\peter\Anaconda3\lib\site-packages\keras\engine\training.py", line 1039, in fit
    validation_steps=validation_steps)
  File "C:\Users\peter\Anaconda3\lib\site-packages\keras\engine\training_arrays.py", line 199, in fit_loop
    outs = f(ins_batch)
  File "C:\Users\peter\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2715, in __call__
    return self._call(inputs)
  File "C:\Users\peter\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2675, in _call
    fetched = self._callable_fn(*array_vals)
  File "C:\Users\peter\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1439, in __call__
    run_metadata_ptr)
  File "C:\Users\peter\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 528, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
         [[{{node conv1d_1/convolution/Conv2D}}]]
         [[{{node metrics/acc/Mean}}]]

我昨晚还是可以训练的,早上就报错了。

发生这个错误的原因是我开了2个tensorflow,他们都要使用GPU。把另外一个程序关了就可以了。

注意:cuda 和cuDNN 的不同版本兼容性可能导致这个问题,显卡驱动太旧也可能导致这个问题

参考这篇文章重装:anaconda python 3.7 tensorflow-gpu安装

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页