Tensorflow: 崩溃:使用 convnet 时无法创建 cuDNN 句柄

创建于 2017-01-06  ·  145评论  ·  资料来源: tensorflow/tensorflow

Tensorflow (GPU) 已成功导入,但在运行涉及卷积神经网络 (CNN) 的会话时,Python 崩溃并显示以下消息:

E tensorflow/stream_executor/cuda/cuda_dnn.cc:385] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:605] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)

在 CUDA 工具包 7.5/8.0 和从 pip/source 安装的 Tensorflow 的任何组合上问题仍然存在。 不使用 CNN 的测试会话成功运行。

通过在网络上搜索您的问题,您发现了哪些相关的 GitHub 问题或 StackOverflow 线程?

这个问题类似于https://github.com/tensorflow/tensorflow/issues/6586 ,我第一次评论的地方。 但是因为我在 Mac 上遇到了这个问题,所以建议我打开一个单独的问题。

环境信息

操作系统:macOS Sierra 10.12.2
Xcode version 8.2 (8C38)(当我后来尝试 CUDA 7.5 时,我安装了命令行工具 7.3.1 版,因为 CUDA 7.5 缺乏对更新编译器的支持。)
Python 3.5.2(蟒蛇)

已安装的 CUDA 版本:尝试了 8.0(最初)和 7.5(此处报告,仅工具包 - 驱动程序仍然是 8.0)
cuDNN安装版本:5.1(根据CUDA版本不同安装)
(请附上ls -l /path/to/cuda/lib/libcud*的输出):

lrwxr-xr-x  1 root   wheel        33  5 Jan 20:33 /usr/local/cuda/lib/libcuda.1.dylib -> /usr/local/cuda/lib/libcuda.dylib
-rwxr-xr-x@ 1 root   wheel      8280 13 Apr  2016 /usr/local/cuda/lib/libcuda.dylib
lrwxr-xr-x@ 1 root   wheel        45 13 Apr  2016 /usr/local/cuda/lib/libcudadevrt.a -> /Developer/NVIDIA/CUDA-7.5/lib/libcudadevrt.a
lrwxr-xr-x@ 1 root   wheel        50 13 Apr  2016 /usr/local/cuda/lib/libcudart.7.5.dylib -> /Developer/NVIDIA/CUDA-7.5/lib/libcudart.7.5.dylib
lrwxr-xr-x@ 1 root   wheel        46 13 Apr  2016 /usr/local/cuda/lib/libcudart.dylib -> /Developer/NVIDIA/CUDA-7.5/lib/libcudart.dylib
lrwxr-xr-x@ 1 root   wheel        49 13 Apr  2016 /usr/local/cuda/lib/libcudart_static.a -> /Developer/NVIDIA/CUDA-7.5/lib/libcudart_static.a
lrwxr-xr-x  1 root   wheel        16  5 Jan 17:14 /usr/local/cuda/lib/libcudnn.5 -> libcudnn.5.dylib
-rwxr-xr-x@ 1 ymfa   staff  58975112 10 Jun  2016 /usr/local/cuda/lib/libcudnn.5.dylib
lrwxr-xr-x@ 1 ymfa   staff        16 10 Jun  2016 /usr/local/cuda/lib/libcudnn.dylib -> libcudnn.5.dylib
lrwxr-xr-x  1 root   wheel        16  5 Jan 17:14 /usr/local/cuda/lib/libcudnn5.dylib -> libcudnn.5.dylib
-rw-r--r--@ 1 ymfa   staff  56392320 10 Jun  2016 /usr/local/cuda/lib/libcudnn_static.a

我尝试从 pip 和源代码安装。 我首先从二进制 pip 包安装:

  1. 指向您安装的 pip 包的链接:
    tensorflow-gpu
  2. python -c "import tensorflow; print(tensorflow.__version__)"的输出。
    0.12.head

后来我从源码安装(pip包被卸载了):

  1. 提交哈希( git rev-parse HEAD
    d67c09d98a576e1fbf2f3609ddb842e53890f31c
  2. bazel version的输出

    构建标签:0.4.3-自制
    构建目标:bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
    构建时间:2016 年 12 月 22 日星期四 15:20:15 (1482420015)
    构建时间戳:1482420015
    将时间戳构建为 int:1482420015

如果可能,请提供一个最小的可重现示例

我通过简化网络并将训练数据减少到只有 20 张图像和两个用于分类的类来制作一个最小的例子。 issue.zip包含 Python 代码和数据。 我写了两个卷积层,因为我发现只有一个卷积层的网络运行没有问题。

使用 CUDA 7.5 和从源代码编译的 Tensorflow 完成日志

I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcublas.7.5.dylib locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcudnn.5.dylib locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcufft.7.5.dylib locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcuda.1.dylib locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcurand.7.5.dylib locally
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:874] OS X does not support NUMA - returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
name: GeForce GT 650M
major: 3 minor: 0 memoryClockRate (GHz) 0.9
pciBusID 0000:01:00.0
Total memory: 1023.69MiB
Free memory: 740.18MiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 650M, pci bus id: 0000:01:00.0)
E tensorflow/stream_executor/cuda/cuda_dnn.cc:385] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:605] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)

使用 CUDA 8.0 和从 pip 安装的 Tensorflow 完成日志

I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.1.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.dylib locally
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] OS X does not support NUMA - returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
name: GeForce GT 650M
major: 3 minor: 0 memoryClockRate (GHz) 0.9
pciBusID 0000:01:00.0
Total memory: 1023.69MiB
Free memory: 590.00MiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 650M, pci bus id: 0000:01:00.0)
E tensorflow/stream_executor/cuda/cuda_dnn.cc:385] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
E tensorflow/stream_executor/cuda/cuda_dnn.cc:392] error retrieving driver version: Invalid argument: expected %d.%d or %d.%d.%d form for driver version; got ""
E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:532] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)
awaiting tensorflower builinstall

最有用的评论

这里有更多关于我如何临时解决它的信息。 我相信这些问题都与GPU内存分配有关,与报告的错误无关。 在此之前还有其他错误表明某种内存分配问题,但程序继续进行,最终给出每个人都得到的 cudnn 错误。 我认为它有时有效的原因是,如果您将 GPU 用于 tensorflow 以外的其他用途,例如您的主显示器,可用内存会波动。 有时你可以分配你需要的东西,有时则不能。

来自 API
https://www.tensorflow.org/versions/r0.12/how_tos/using_gpu/
“默认情况下,TensorFlow 映射了进程可见的所有 GPU(受 CUDA_VISIBLE_DEVICES)的几乎所有 GPU 内存。这样做是为了通过减少内存碎片来更有效地使用设备上相对宝贵的 GPU 内存资源。”

我认为这种默认分配以某种方式被破坏,导致这种不稳定的行为和某些情况起作用,而其他情况则失败。

我通过更改 TF 的默认行为来分配最小内存量并根据网页中详细说明的需要增长来解决此问题。
配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)

我也尝试过另一种方法,并且能够让它工作,但通过实验选择一个有效的百分比而失败。 就我而言,它最终约为 0.7。

配置 = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.4
session = tf.Session(config=config, ...)

仍然没有来自 TF 团队中任何人的消息证实这一点,但值得一试,看看其他人是否可以确认类似的行为。

所有145条评论

I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties:
name: GeForce GTX 1080
major: 6 minor: 1 memoryClockRate (GHz) 1.835
pciBusID 0000:02:00.0
Total memory: 7.92GiB
Free memory: 3.76GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:02:00.0)
E tensorflow/stream_executor/cuda/cuda_dnn.cc:385] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:532] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)

我遇到了与您使用 CUDA8 和 TF r0.12.1 时遇到的完全相同的问题。

@EncodeTS我刚刚在我的第一篇文章中添加了一个最小的可重现示例。 你能检查一下它是否在你的机器上重现了这个问题吗? 在我的机器上,一个卷积层有效,但两个卷积层无效,这让我认为问题可能是由某些资源限制引起的。

我可以确认@ymfa最小示例在 MacOS NVidia 750 上失败,但同样的示例也适用于 Linux/Titan X

最小的例子适用于我的 Ubuntu。 看起来我遇到的问题在我的电脑上发生的概率非常低。

我遇到了同样的问题。 当强制到 cpu 时,图形将运行良好,但在 gpu 上崩溃。

环境

操作系统:macOS 10.12.2
GPU:GeForce GT 750M
TF: 0.12.1 (pip 安装)
蟒蛇:3.6.0
CUDA:8.0
cuDNN:5.1

ls -l /path/to/cuda/lib/libcud* ):

lrwxr-xr-x  1 root  wheel     33 Dec 14 14:25 /usr/local/cuda/lib/libcuda.1.dylib -> /usr/local/cuda/lib/libcuda.dylib
-rwxr-xr-x  1 root  wheel  13504 Dec  2 16:48 /usr/local/cuda/lib/libcuda.dylib
lrwxr-xr-x  1 root  wheel     45 Nov  3 11:40 /usr/local/cuda/lib/libcudadevrt.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcudadevrt.a
lrwxr-xr-x  1 root  wheel     50 Nov  3 11:40 /usr/local/cuda/lib/libcudart.8.0.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart.8.0.dylib
lrwxr-xr-x  1 root  wheel     46 Nov  3 11:40 /usr/local/cuda/lib/libcudart.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart.dylib
lrwxr-xr-x  1 root  wheel     49 Nov  3 11:40 /usr/local/cuda/lib/libcudart_static.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcudart_static.a
lrwxr-xr-x  1 root  wheel     47 Dec 14 10:21 /usr/local/cuda/lib/libcudnn.5.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudnn.5.dylib
lrwxr-xr-x  1 root  wheel     45 Dec 14 10:21 /usr/local/cuda/lib/libcudnn.dylib -> /Developer/NVIDIA/CUDA-8.0/lib/libcudnn.dylib
lrwxr-xr-x  1 root  wheel     48 Dec 14 10:21 /usr/local/cuda/lib/libcudnn_static.a -> /Developer/NVIDIA/CUDA-8.0/lib/libcudnn_static.a

例子

@ymfa提供的最小示例在我的设置中既失败又成功。 以下是已产生的三个输出。
失败(1)

I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.1.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.dylib locally
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] OS X does not support NUMA - returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
name: GeForce GT 750M
major: 3 minor: 0 memoryClockRate (GHz) 0.9255
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.76GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
Training...
E tensorflow/stream_executor/cuda/cuda_dnn.cc:385] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:532] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms) 
Abort trap: 6

失败(2)

I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.1.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.dylib locally
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] OS X does not support NUMA - returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
name: GeForce GT 750M
major: 3 minor: 0 memoryClockRate (GHz) 0.9255
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.53GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
Training...
E tensorflow/stream_executor/cuda/cuda_blas.cc:372] failed to create cublas handle: CUBLAS_STATUS_NOT_INITIALIZED
W tensorflow/stream_executor/stream.cc:1390] attempting to perform BLAS operation using StreamExecutor without BLAS support
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1021, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1003, in _run_fn
    status, run_metadata)
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 89, in __exit__
    next(self.gen)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 469, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InternalError: Blas SGEMM launch failed : a.shape=(20, 400), b.shape=(400, 2), m=20, n=2, k=400
     [[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](Flatten/Reshape, Variable_4/read)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "issue.py", line 52, in <module>
    sess.run(training_operation, feed_dict={x: X, y: Y})
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 766, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 964, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1014, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1034, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InternalError: Blas SGEMM launch failed : a.shape=(20, 400), b.shape=(400, 2), m=20, n=2, k=400
     [[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](Flatten/Reshape, Variable_4/read)]]

Caused by op 'MatMul', defined at:
  File "issue.py", line 43, in <module>
    logits = SimpleNet(x)
  File "issue.py", line 34, in SimpleNet
    logits = tf.matmul(fc1, fc1_W) + fc1_b
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 1729, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1442, in _mat_mul
    transpose_b=transpose_b, name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1128, in __init__
    self._traceback = _extract_stack()

InternalError (see above for traceback): Blas SGEMM launch failed : a.shape=(20, 400), b.shape=(400, 2), m=20, n=2, k=400
     [[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](Flatten/Reshape, Variable_4/read)]]

经过

I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.1.dylib locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.dylib locally
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] OS X does not support NUMA - returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
name: GeForce GT 750M
major: 3 minor: 0 memoryClockRate (GHz) 0.9255
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.71GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
Training...
Training complete!

由于最近没有活动而自动关闭。 请在有新信息可用时更新问题,我们将重新打开问题。 谢谢!

没那么快,我也看到了这个崩溃。 Macbook pro,geforce 650。TF v1。 通过 jupyter 内核运行,我必须经常重启。 也许这显卡太弱了? 看看操作员如何使用同一张卡:很可能。

I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.8.0.dylib locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.5.dylib locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.8.0.dylib locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.1.dylib locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.8.0.dylib locally
...
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
name: GeForce GT 650M
major: 3 minor: 0 memoryClockRate (GHz) 0.9
pciBusID 0000:01:00.0
Total memory: 1023.69MiB
Free memory: 870.46MiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 650M, pci bus id: 0000:01:00.0)
E tensorflow/stream_executor/cuda/cuda_dnn.cc:397] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:364] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:605] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms) 

我对 GTX 960m、cudnn5.1.5 和 cuda-8.0.44 也有同样的问题。

centOS 有同样的问题,titan X

与 ubuntu(14.04) 和 GRID K520 (aws g2.2) 有同样的问题

有同样的问题 windows 10 cudnn 5.1 cuda 8 gtx 1060。程序在张量流的 cpu 版本上工作,但在 gpu 版本上出现这些相同的错误。

我在 gtx1060、win8.1、cuda8.0.60、cudnn5.0 上遇到了同样的问题。 升级到最新的稳定版 tensorflow-gpu nightly build(目前为 http://ci.tensorflow.org/job/nightly-win/133/)和 cudnn5.1。 问题解决了。

同样的问题在这里。

我在下面列出的软件版本中遇到了这个问题,除了 TF 是 1.0.0 版。 然后我升级到 TF 1.0.1。 我曾经运行过同一个程序,它奏效了。 然后我再次运行它,但它不起作用——它产生了与以前相同的错误。

Tensorflow-GPU 1.0.1
Mac OS X 10.12.3
CUDA 8.0.61
CuDNN 5.1
GeForce GT 750M

与 gtx650、ubuntu 16.04、CUDA 版本 8.0.61、TF 版本 1.0.0 有同样的问题
它刚刚工作,但给出了一些低内存警告。 然而,它正在运行
现在它根本不运行,给我同样的 Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms) 错误

与 gtx 1080 ti、windows 10、CUDA 版本 8.0.61、TF 版本 1.0.1、5.1 Cudann、cuda 8.0.61 有同样的问题

我能够通过限制 gpu 使用来让程序运行。 在我在 ubuntu 16.04 上使用 3gb gtx 1060 的情况下,如果我将 gpu 选项 per_process_gpu_memory_fraction 设置为 0.7,它就可以工作。 任何更高的,我都会收到这些错误

E tensorflow/stream_executor/cuda/cuda_dnn.cc:397] 无法创建 cudnn 句柄:CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:364] 无法销毁 cudnn 句柄:CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:605] 检查失败:stream->parent()->GetConvolveAlgorithms(&algorithms)

这可能是 tensorflow 错误报告的一种情况。 似乎完全不相关。 也许这是以更好的方式解决这个问题的线索?

@zheng-xq 有明显的设置问题吗?

同样的问题。 我使用的是 Windows 10、GTX1070、CUDA 8.0、cuDNN 5.1。

E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:359] 无法创建 cudnn 句柄:CUDNN_STATUS_NOT_INITIALIZED
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:366]错误检索驱动程序版本:未实现:内核报告驱动程序版本未在Windows上实现
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:326] 无法销毁 cudnn 句柄:CUDNN_STATUS_BAD_PARAM
F c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\kernels\conv_ops.cc:659] 检查失败:stream->parent()->GetConvolveAlgorithms(&algorithms)

如果它对任何人有帮助,似乎有时会留下僵尸进程,这会阻止 tf 重新正确启动并给我这个错误。 杀死他们可以解决这个问题。

这里有更多关于我如何临时解决它的信息。 我相信这些问题都与GPU内存分配有关,与报告的错误无关。 在此之前还有其他错误表明某种内存分配问题,但程序继续进行,最终给出每个人都得到的 cudnn 错误。 我认为它有时有效的原因是,如果您将 GPU 用于 tensorflow 以外的其他用途,例如您的主显示器,可用内存会波动。 有时你可以分配你需要的东西,有时则不能。

来自 API
https://www.tensorflow.org/versions/r0.12/how_tos/using_gpu/
“默认情况下,TensorFlow 映射了进程可见的所有 GPU(受 CUDA_VISIBLE_DEVICES)的几乎所有 GPU 内存。这样做是为了通过减少内存碎片来更有效地使用设备上相对宝贵的 GPU 内存资源。”

我认为这种默认分配以某种方式被破坏,导致这种不稳定的行为和某些情况起作用,而其他情况则失败。

我通过更改 TF 的默认行为来分配最小内存量并根据网页中详细说明的需要增长来解决此问题。
配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)

我也尝试过另一种方法,并且能够让它工作,但通过实验选择一个有效的百分比而失败。 就我而言,它最终约为 0.7。

配置 = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.4
session = tf.Session(config=config, ...)

仍然没有来自 TF 团队中任何人的消息证实这一点,但值得一试,看看其他人是否可以确认类似的行为。

我也收到CUDNN_STATUS_NOT_INITIALIZED错误。 这是完整的错误日志:

2017-04-26 00:08:57.526234: I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0)
2017-04-26 00:09:01.111706: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:359] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2017-04-26 00:09:01.111805: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:366] error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows
2017-04-26 00:09:01.114040: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:326] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2017-04-26 00:09:01.114232: F c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\kernels\conv_ops.cc:659] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)

我在 Windows 10、CUDA 8.0、cuDNN 5.1 上。 有什么办法可以避免这些吗? 我能够更早地运行其他一些 tensorflow 测试并且它运行良好(包括转换操作),但现在它不适用于这个新测试......

@serans1你指的是什么僵尸进程?

请让我知道是否有解决方法。 谢谢!

编辑这可能是一个新手错误,但我只会在这里提到它,以防其他人遇到同样的问题:
我的问题是我已经运行了一个 Jupyter Python Notebook 实例(其单元已经全部运行,因此加载到内存中),以及其他一些占用 GPU 内存的进程(最小化视频游戏)。 因此,当我检查 GPU 上的内存使用情况时,它已经在 4+GB (50+%) 左右。 我关闭了 Jupyter Notebook 和其他应用程序,并重新运行了我的 tensorflow 测试。 现在一切运行顺利 :) 此外,在运行时,我注意到在峰值时它使用了我的 GPU 内存的 90%,因此当它在我的初始情况下可用不到 50% 时它无法初始化 CUDNN 是有道理的.

再次为我的错误道歉! 我刚刚开始玩这个:)

同样的问题,请问有解决办法吗?

我 c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:885] 找到具有属性的设备 0:
名称:GeForce GTX 960M
主要:5 次要:0 memoryClockRate (GHz) 1.176
pciBusID 0000:01:00.0
总内存:4.00GiB
可用内存:3.35GiB
我 c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:906] DMA:0
我 c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:916] 0: Y
我 c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:975] 创建 TensorFlow 设备 (/gpu:0) -> (device: 0,名称:GeForce GTX 960M,pci 总线 id:0000:01:00.0)
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:586] 无法识别 /job:localhost/replica:0 的 NUMA 节点/task:0/gpu:0,默认为 0。您的内核可能没有使用 NUMA 支持构建。
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:385] 无法创建 cudnn 句柄:CUDNN_STATUS_NOT_INITIALIZED
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:392] error retrieving driver version: Permission denied: could not open driver version path for reading : /proc/driver/nvidia/version
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:352] 无法销毁 cudnn 句柄:CUDNN_STATUS_BAD_PARAM
F c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\kernels\conv_ops.cc:532] 检查失败:stream->parent()->GetConvolveAlgorithms(&algorithms)

我有完全相同的问题。
但是我可以使用 root 访问权限(使用 sudo)运行我的代码。
目前我正在使用 GTX 960 开发 Ubuntu 16.04。
我的 CUDA 版本是 8.0,我使用的是 tensorflow 1.01

Windows 10 / TensorFlow 1.01
我正在完美地使用它,但现在不小心发生了同样的错误

名称:GeForce GTX 1070
主要:6 次要:1 memoryClockRate (GHz) 1.7715
pciBusID 0000:03:00.0
总内存:8.00GiB
可用内存:6.68GiB
2017-05-08 21:12:16.103654:我 c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:908] DMA:0
2017-05-08 21:12:16.105184:我 c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:918] 0: Y
2017-05-08 21:12:16.106710:我 c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:977] 创建 TensorFlow 设备(/gpu:0) ->(设备:0,名称:GeForce GTX 1070,pci 总线 ID:0000:03:00.0)
2017-05-08 21:12:24.395060: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:359] 无法创建 cudnn 句柄:CUDNN_STATUS_NOT_INITIALIZED
2017-05-08 21:12:24.395177: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:366] 检索驱动程序版本时出错:未实现:内核报告的驱动程序版本未在 Windows 上实现
2017-05-08 21:12:24.396636: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:326] 无法销毁 cudnn 句柄:CUDNN_STATUS_BAD_PARAM
2017-05-08 21:12:24.396846: F c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\kernels\conv_ops.cc:659] 检查失败:流- >parent()->GetConvolveAlgorithms(&algorithms)

@strickon的方法对我

config.gpu_options.allow_growth = True

确认@strickon的建议对我

我正在运行https://github.com/awjuliani/DeepRL-Agents/blob/master/Double-Dueling-DQN.ipynb并且在更新块中第一次调用 sess.run 时遇到了此线程中提到的故障(行: Q1 = sess.run(mainQN.predict,feed_dict={mainQN.scalarInput:np.vstack(trainBatch[:,3])})

添加 allow_growth 标志(如下所示)让我克服了这个障碍 - 代码当前在后台运行,我们将看到它走多远。

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

堆:

  • MacBook Pro,运行 Sierra 10.12.4,配备 NVIDIA GeForce GT 750M 2048 MB。 通常只有 1.7GB 可用空间。
  • TensorFlow 1.1使用 Anaconda 安装说明。
  • Python 3.6,不是虚拟的(Anaconda)
  • CUDA 8 / cuDNN 5

我可以根据要求转储更多统计数据。

我同时使用两个终端并且遇到了同样的问题。 它是通过关闭一个终端来解决的。

由于最近没有活动而自动关闭。 请在有新信息可用时更新问题,我们将重新打开问题。 谢谢!

实施@stricon建议的更改后,我开始看到一组新的信息日志出现:

2017-06-23 04:45:57.156787: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\pool_allocator.cc:247] PoolAllocator: After 3205 get requests, put_count=2333 evicted_count=1000 eviction_rate=0.428633 and unsatisfied allocation rate=0.615289
2017-06-23 04:45:57.156880: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\pool_allocator.cc:259] Raising pool_size_limit_ from 100 to 110
step 0 - loss = 5.632, (19.351 sec/step)

不确定是否相关。

同样的错误在这里。

Windows 10 x86_64、GeForce GTX 970、驱动程序 376.53、Cuda 8.0、cuDNN 5.1.、来自 pip 的 tensorflow-gpu 1.2.0、python 3.6

我正在尝试从网站的教程部分运行默认示例:

https://www.tensorflow.org/tutorials/image_recognition

python classify_image.py

我有同样的错误:

`
``
(C:\ProgramData\Anaconda3) C:\Users\Locky\Google Диск\MachineLearning\Tensorflow-Tutorials\Repo\models\tutorials\image\imagenet>pythonclassify_image.py
2017-06-25 18:36:32.318287:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] TensorFlow 库未编译为使用 SSE 指令,但这些指令可在您的机器上使用并且可以加速 CPU 计算。
2017-06-25 18:36:32.318514:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] TensorFlow 库没有被编译为使用 SSE2 指令,但这些在您的机器上可用并且可以加速 CPU 计算。
2017-06-25 18:36:32.323556:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] TensorFlow 库没有被编译为使用 SSE3 指令,但这些在您的机器上可用并且可以加速 CPU 计算。
2017-06-25 18:36:32.323719:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] TensorFlow 库未编译为使用 SSE4.1 指令,但这些指令可在您的机器上使用并且可以加速 CPU 计算。
2017-06-25 18:36:32.323834:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] TensorFlow 库没有被编译为使用 SSE4.2 指令,但这些在您的机器上可用并且可以加速 CPU 计算。
2017-06-25 18:36:32.323930:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] TensorFlow 库没有被编译为使用 AVX 指令,但这些在您的机器上可用并且可以加速 CPU 计算。
2017-06-25 18:36:32.324205:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] TensorFlow 库未编译为使用 AVX2 指令,但这些指令可在您的机器上使用并且可以加速 CPU 计算。
2017-06-25 18:36:32.324351:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] TensorFlow 库未编译为使用 FMA 指令,但这些指令可在您的机器上使用并且可以加速 CPU 计算。
2017-06-25 18:36:32.707933:我 c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:940] 发现具有属性的设备 0:
名称:GeForce GTX 970
主要:5 次要:2 memoryClockRate (GHz) 1.253
pciBusID 0000:01:00.0
总内存:4.00GiB
可用内存:3.31GiB
2017-06-25 18:36:32.708332:我 c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:961] DMA : 0
2017-06-25 18:36:32.713764:我 c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0 : 是
2017-06-25 18:36:32.713991:我 c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] 创建TensorFlow 设备 (/gpu:0) ->(设备:0,名称:GeForce GTX 970,pci 总线 ID:0000:01:00.0)
2017-06-25 18:36:34.854555:W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\framework\op_def_util.cc:332] Op BatchNormWithGlobalNormalization 是已弃用。 它将停止在 GraphDef 版本 9 中工作。使用 tf.nn.batch_normalization()。
2017-06-25 18:36:35.836895: E c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\stream_executor\cuda\cuda_dnn.cc:359] 无法创建cudnn 句柄:CUDNN_STATUS_NOT_INITIALIZED
2017-06-25 18:36:35.837068: E c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\stream_executor\cuda\cuda_dnn.cc:366] 错误检索驱动程序版本:未实现:内核报告驱动程序版本未在 Windows 上实现
2017-06-25 18:36:35.841593: E c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\stream_executor\cuda\cuda_dnn.cc:326] 无法销毁cudnn 句柄:CUDNN_STATUS_BAD_PARAM
2017-06-25 18:36:35.841690: F c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\kernels\conv_ops.cc:671] 检查失败:流->parent()->GetConvolveAlgorithms(&algorithms)

(C:\ProgramData\Anaconda3) C:\Users\Locky\Google Диск\MachineLearning\Tensorflow-Tutorials\Repo\models\tutorials\image\imagenet>

````

就我而言,发生这种情况是因为其他 tensorflow 实例持有 GPU。 (其他脚本正在运行。)

我可以提出更好的错误信息吗? 说,“错误:其他 tensorflow 实例正在运行,而只支持一个。”

我有同样的问题。 运行 macOS 10.12.5 GT 750M 2GB

python neural_style.py --content /Users/qinyuhang/Pictures/0.jpeg  --styles IMG_1105.JPG --output 1.out.jpg --iterations 500
2017-07-05 22:16:54.531699: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:857] OS X does not support NUMA - returning NUMA node zero
2017-07-05 22:16:54.532257: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties: 
name: GeForce GT 750M
major: 3 minor: 0 memoryClockRate (GHz) 0.9255
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.54GiB
2017-07-05 22:16:54.532435: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0 
2017-07-05 22:16:54.532461: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0:   Y 
2017-07-05 22:16:54.532471: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
2017-07-05 22:17:07.284016: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
2017-07-05 22:17:44.973549: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
Optimization started...
Iteration    1/ 500
2017-07-05 22:17:47.485948: E tensorflow/stream_executor/cuda/cuda_dnn.cc:359] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
2017-07-05 22:17:47.485977: E tensorflow/stream_executor/cuda/cuda_dnn.cc:326] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2017-07-05 22:17:47.485983: F tensorflow/core/kernels/conv_ops.cc:671] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms) 
[1]    66448 abort      python neural_style.py --content /Users/qinyuhang/Pictures/0.jpeg --styles   

解决了它(至少对我来说)。 错误消息不会引导您解决正确的问题。 我从 2 个不同的来源收到此错误:

首先(就像@lockywolf说的):
我使用 jupyter notebook,有时 TF 内核不会释放 GPU 内存,您必须重新启动 jupyter 才能使其再次工作。 这通常发生在运行时错误或不正确的内核重新启动之后......

第二:
有时你会贪婪地使用 GPU 内存并尝试这样的事情:

gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.9)
sess = tf.InteractiveSession(config=tf.ConfigProto(gpu_options=gpu_options))

这对我的配置来说是致命的,并开始出现此错误。 解决方案是使用默认方式启动交互式会话
sess = tf.InteractiveSession()

系统:

Ubuntu 14.04
英伟达 GTX 780
CUDA 驱动程序版本 = 8.0
CUDNN 版本 = 5.1
TensorFlow 版本 = 1.2.1

我现在在运行自己的脚本时遇到了同样的问题。
我认为这与@lockywolf描述的原因相同:

就我而言,发生这种情况是因为其他 tensorflow 实例持有 GPU。 (其他脚本正在运行。)

我经常遇到这个错误但不规则,然后我按照@RawthiL的指导添加了一个会话到我的脚本中。 但是,我执行脚本成功重新启动内核并再次收到相同的错误消息。 是否有任何解决方案可以打开会话,声明 GPU 并在计算完成后关闭它?

干杯!

编辑:
除了@RawthiL的解决方案,我遵循了Keras TF 介绍,他们说:

我们应该首先创建一个 TensorFlow 会话并将其注册到 Keras。 这意味着 Keras 将使用我们注册的会话来初始化它内部创建的所有变量。

将张量流导入为 tf
sess = tf.Session()

从 keras 导入后端为 K
K.set_session(sess)

同样的问题。 一整天都在努力争取让这个工作。

$ ~/neural-style$ python neural_style.py --content ~/Documents/8UhFDcjT.jpg --styles ~/Documents/9odz6-jbngd.png --output ./Documents/Scott.png
2017-07-26 20:57:08.373361: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-26 20:57:08.373397: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-26 20:57:08.373413: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-07-26 20:57:08.373417: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-26 20:57:08.373421: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-07-26 20:57:08.431319: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-07-26 20:57:08.431630: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties: 
name: GeForce GTX 870M
major: 3 minor: 0 memoryClockRate (GHz) 0.967
pciBusID 0000:01:00.0
Total memory: 2.95GiB
Free memory: 2.53GiB
2017-07-26 20:57:08.431664: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0 
2017-07-26 20:57:08.431674: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0:   Y 
2017-07-26 20:57:08.431690: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 870M, pci bus id: 0000:01:00.0)
2017-07-26 20:57:11.692616: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 870M, pci bus id: 0000:01:00.0)
2017-07-26 20:57:19.800938: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 870M, pci bus id: 0000:01:00.0)
Optimization started...
Iteration    1/1000
2017-07-26 20:57:20.535515: E tensorflow/stream_executor/cuda/cuda_dnn.cc:359] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
2017-07-26 20:57:20.535573: E tensorflow/stream_executor/cuda/cuda_dnn.cc:326] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2017-07-26 20:57:20.535588: F tensorflow/core/kernels/conv_ops.cc:671] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms) 

我发现在某些情况下重置 jupyter 内核不起作用。 实际上它发生在我使用 jupyterhub 时。
我重新启动了内核,停用了我的 virtualenv,GPU 内存仍然被某个进程占用。 nvidia-smi命令表示没有使用 GPU 的进程,当我尝试用sudo nvidia-smi --gpu-reset -i 0 (对于 0 gpu 内核)重置它时,它说如下:

无法重置此 GPU,因为它正被某些其他进程(例如 CUDA 应用程序、像 X 服务器这样的图形应用程序、像其他 nvidia-smi 实例的监视应用程序)使用。 请首先终止使用此 GPU 的所有进程以及系统中运行的所有计算应用程序(即使它们在其他 GPU 上运行),然后再次尝试重置 GPU。
由于先前的错误而提前终止。

所以有一些进程持有 GPU,我使用sudo fuser -v /dev/nvidia*寻找它们,它说实际上有一些东西持有 GPU...python 本身...杀死它并重新启动 virtualenv 和 jupyter 做了诡计。
我可能不是解决此问题的最佳方法,但比在所有其他选项都失败时重置计算机要好。

有同样的问题。 GPU 为 GTX 1070 和 CUDA 8.0 以及用于 CUDA 8.0 的 CUDNN 5.1。

问题不取决于用户代码,它取决于硬件或 Nvidia 或 Google 软件状态。 此错误可能随时开始上升,重新启动可以使用相同的用户代码修复它。

与 Windows 10、GTX770、CUDA 8.0、CUDNN 5.1、TF-GPU 1.1.0 相同的问题,不确定从哪里获取设备驱动程序版本,但 Windows 设备管理器报告显示驱动程序为 21.21.13.7651。

connect  84557d348c06492e80ff0304d516367b
2017-08-11 15:51:41.974028: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:359] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2017-08-11 15:51:41.974536: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:366] error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows
2017-08-11 15:51:41.974923: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:326] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2017-08-11 15:51:41.975194: F c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\kernels\conv_ops.cc:659] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)

与 Windows 10、GTX770、CUDA 8.0、CUDNN 5.1、TF-GPU 1.1.0 相同的问题,不确定从哪里获取设备驱动程序版本,但 Windows 设备管理器报告显示驱动程序为 21.21.13.7651。

connect  84557d348c06492e80ff0304d516367b
2017-08-11 15:51:41.974028: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:359] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2017-08-11 15:51:41.974536: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:366] error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows
2017-08-11 15:51:41.974923: E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:326] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2017-08-11 15:51:41.975194: F c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\kernels\conv_ops.cc:659] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)

@ggranum的修复对我

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

在我的情况下,通过更新 NVIDIA gpu 驱动程序解决了同样的问题。

这个问题有没有彻底解决。 我正在使用 CUDA 8.0 和 cuDNN 5.1 在 Ubuntu 16.04 上运行 TF 1.3.0。 我使用 Anaconda 来安装我的软件包。 随机 4 天前,我也遇到了这个错误

name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate (GHz) 1.582 pciBusID 0000:05:00.0 Total memory: 10.91GiB Free memory: 10.30GiB 2017-09-05 07:47:05.397839: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x30028e0 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that. 2017-09-05 07:47:05.401343: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 1 with properties: name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate (GHz) 1.582 pciBusID 0000:06:00.0 Total memory: 10.91GiB Free memory: 10.75GiB 2017-09-05 07:47:05.658932: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x2ffe910 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that. 2017-09-05 07:47:05.659690: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 2 with properties: name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate (GHz) 1.582 pciBusID 0000:09:00.0 Total memory: 10.91GiB Free memory: 10.75GiB 2017-09-05 07:47:05.898536: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x2ffa940 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that. 2017-09-05 07:47:05.899294: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 3 with properties: name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate (GHz) 1.582 pciBusID 0000:0a:00.0 Total memory: 10.91GiB Free memory: 10.75GiB 2017-09-05 07:47:05.903197: I tensorflow/core/common_runtime/gpu/gpu_device.cc:976] DMA: 0 1 2 3 2017-09-05 07:47:05.903209: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 0: Y Y Y Y 2017-09-05 07:47:05.903215: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 1: Y Y Y Y 2017-09-05 07:47:05.903218: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 2: Y Y Y Y 2017-09-05 07:47:05.903223: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 3: Y Y Y Y 2017-09-05 07:47:05.903236: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:05:00.0) 2017-09-05 07:47:05.903242: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:06:00.0) 2017-09-05 07:47:05.903248: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:2) -> (device: 2, name: GeForce GTX 1080 Ti, pci bus id: 0000:09:00.0) 2017-09-05 07:47:05.903252: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:3) -> (device: 3, name: GeForce GTX 1080 Ti, pci bus id: 0000:0a:00.0) 2017-09-05 07:47:20.297138: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:05:00.0) 2017-09-05 07:47:20.297190: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:06:00.0) 2017-09-05 07:47:20.297206: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:2) -> (device: 2, name: GeForce GTX 1080 Ti, pci bus id: 0000:09:00.0) 2017-09-05 07:47:20.297220: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:3) -> (device: 3, name: GeForce GTX 1080 Ti, pci bus id: 0000:0a:00.0) 2017-09-05 07:47:24.845499: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:05:00.0) 2017-09-05 07:47:24.845534: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:06:00.0) 2017-09-05 07:47:24.845542: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:2) -> (device: 2, name: GeForce GTX 1080 Ti, pci bus id: 0000:09:00.0) 2017-09-05 07:47:24.845548: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:3) -> (device: 3, name: GeForce GTX 1080 Ti, pci bus id: 0000:0a:00.0) 2017-09-05 07:47:34.884524: E tensorflow/stream_executor/cuda/cuda_dnn.cc:371] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR 2017-09-05 07:47:34.884597: E tensorflow/stream_executor/cuda/cuda_dnn.cc:338] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM 2017-09-05 07:47:34.884616: F tensorflow/core/kernels/conv_ops.cc:672] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms)

我有 4 个 1080ti GPU。 在我的模型运行期间,我监控了 nvidia-smi 并得到了

-------------------------------------------------- ---------------------------+
| 进程:GPU 内存 |
| GPU PID 类型进程名称用法|
|================================================== ==============================|
| 0 1422 G /usr/lib/xorg/Xorg 279MiB |
| 0 3530 G compiz 195MiB |
| 0 11249 C /home/simon/anaconda3/bin/python 10157MiB |
| 1 11249 C /home/simon/anaconda3/bin/python 10611MiB |
| 2 11249 C /home/simon/anaconda3/bin/python 10611MiB |
| 3 11249 C /home/simon/anaconda3/bin/python 10611MiB |
+------------------------------------------------- -----------------------------+

所以出于某种原因,Python 正在占用内存。 当然,如果我杀死它,它就会杀死我的 jupyter 笔记本。 我没有运行僵尸进程。 我试过了。

gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.1) sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))

这确实减少了 GPU 使用率,但我仍然遇到相同的 cuDDN 处理错误。 我已经重新安装了TF。 CUDA、cuDNN、Anaconda 对问题没有影响。

为什么这个错误会随机发生,如何解决。

TensorFlow 1.3 是针对 cuDNN 6 构建的。
请升级您的 cuDNN 安装。

谢谢,古南 - 不幸的是,这没有区别。 即使使用 cuDNN 6,我仍然遇到 cuDNN 无法创建句柄错误。 即使直接设置 GPUptions 也不能防止错误,尽管它确实减少了 GPU 内存的使用量。 GPU 内存被 Python 占用,所以如果我关闭它,它会关闭我的 Jupyter 笔记本。 我已经坚持了近 4 天,似乎已经用尽了我在网上看到的所有建议。 这可能是 TF 1.3 问题吗?

只为那些为此而发疯的人:

我偶尔也会遇到 CUBLAS 错误。 所以我这样做了:

cd /usr/local/cuda/samples/7_CUDALibraries/simpleCUBLAS
make
./simpleCUBLAS

并发现我无法初始化 CUBLAS

所以接下来我做了这个(基于建议)

sudo rm -f ~/.nv

它奏效了。 干杯……浪费了4天。 希望这能拯救别人

@SimonWalsh1000有效!! 谢谢

检查您的主路径中的 .theanorc(如果是 Ubuntu),并将 cnmem 设置得更小....也许 cnmem=0.8,它现在对我有用

我让它在带有 GTX 1070 的 Windows 10 下完美运行。
我正在使用 cudnn 7.0.2
降级到 vs 6.0 解决了我的问题:

cuda_8.0.61_win10.exe
cudnn-8.0-windows10-x64-v6.0.zip
python-3.6.2-amd64.exe

把整个安装过程贴在这里:
http://klaatuveratanecto.com/installing-tensorflow-gpu-windows-10-running-image_retraining/

你好,我也有同样的问题。 但是,我发现原因是我同时使用了两次tensorflow。

例如,我通常使用 Jupyter notebook 编写简单脚本,使用 PyCharm 编写项目。 如果我没有关闭 jupyter notebook ,我可能会在 Pycharm 中遇到这个错误。

希望这能有所帮助。


WINDOWS10 64,
英伟达 TitanX,
驱动程序 385.41,
CUDA 8.0.60
卡顿 6.0
蟒蛇 3.5.2
张量流 1.3

我同意@stricon :这似乎是一个内存分配问题。
我有一个运行 tensorflow 程序的笔记本,我尝试在另一个 Windows 终端中运行 python + tensorflow 并得到错误。 然后我重新启动了我的笔记本(释放 GPU 内存)并尝试再次在 Windows 终端上运行 python 并且它起作用了! 我认为 tensorflow 应该提供更好的错误信息,以更详细的解释建议用户。

我在 Windows 10、cuda 8 和 cudnn 6 上使用:

名称: Quadro K620
主要:5 次要:0 memoryClockRate (GHz) 1.124
pciBusID 0000:01:00.0
总内存:2.00GiB
可用内存:1.66GiB

几乎相同的步骤也适用于我,我几乎不了解它是如何工作的。 我只是关闭了所有窗口,关闭了在 pycharm 上打开的 python 终端——包括那些由同一程序的早期执行打开的窗口,用于绘制训练进度并重新打开和运行——它没有错误。 之前报告的错误似乎没有给出直接线索——

你好,
我遇到了同样的问题,使用 sudo 运行 python 解决了我的问题。

@SimonWalsh1000你是我的英雄!! 它也适用于我!

@hesamaraghisudo一起跑步也帮助了我们。 通过将我们的非 root 用户添加到nvidia-persistenced组,我们能够以非 root 身份运行。 见我原来的评论: https :

我在 Ubuntu 16.04 和 cuda-8.0(使用 GTX1080Ti)中遇到了同样的问题。 我只是想通知你们中的任何一个有同样问题的人, @SimonWalsh1000给出的解决方案非常适合我(即 CUBLAS 初始化问题由sudo rm -rf ~/.nv/ )。 所以,非常感谢@SimonWalsh1000 ,它确实花了我几个小时......

@SimonWalsh1000确实有效。 非常感谢!

@SimonWalsh1000它就像一个魅力,谢谢!!!!

我在 Windows 10、CUDA 8.0、cuDNN 6.1 和 GTX1070Ti 上遇到了同样的问题。
我找到了原因:我在 annconda spyder IDE 中运行了 tensorflow 代码,之后我在 annconda 提示符中运行了另一个 tensorflow 代码。
通过关闭 spyder IDE 解决它
@lockywolf是对的

我有同样的问题。 我尝试了@stricon的方法,但我不知道“nvidia-smi”可能是 Linux 上的命令。 我通过将CUDA8.0 的 cuDNN 6.0更新cuDNN 7.0解决了这个问题

开始时的系统:

  • 视窗10
  • CUDA8.0
  • cuDNN6.0
  • 蟒蛇3.5(python3.5)
  • GeForce 840M 主要:5 次要:0 memoryClockRate(GHz):1.124
  • 2.00GiB 空闲内存:1.66GiB

解决后的系统:

  • 视窗10
  • CUDA8.0
  • cuDNN7.0
  • 蟒蛇3.5(python3.5)
  • GeForce 840M 主要:5 次要:0 memoryClockRate(GHz):1.124
  • 2.00GiB 空闲内存:1.66GiB

我觉得这个问题可能是库和硬件版本不匹配导致的。 @chleibig也通过更新 GPU 驱动程序解决了这个问题。 希望这会有所帮助。

对我来说: config.gpu_options.allow_growth = True在 tensorflow 会话中解决了这个问题。
Cuda 8、tf 1.4、cudnn 6

运行此修复问题。

须藤 rm -rf ~/.nv

同样的问题。 有什么办法可以解决问题吗?
我的情况是:
名称:GeForce GTX 1080
总内存:7.92GiB 空闲内存:2.50GiB
张量流:GPU-1.4.0

我正在测试一个 gpu 但运行三个 tensorflow 实例。
在我的代码中是这样的:
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.3)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))

其他两个 tensorflow 实例运行良好,但只有最后一个运行错误,如下所示:

E tensorflow/stream_executor/cuda/cuda_dnn.cc:371] 无法创建 cudnn 句柄:CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:338] 无法销毁 cudnn 句柄:CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:672] 检查失败:stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo(), &算法)

为什么? gpu 配置是否太小:gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.3)
我不知道。 想要一些建议。 我会尽力。

看看我的解决方案......

2017年12月在08:20 19,tbchj [email protected]写道:

同样的问题。 有什么办法可以解决问题吗?
我的情况是:
名称:GeForce GTX 1080
总内存:7.92GiB 空闲内存:2.50GiB
张量流:GPU-1.4.0

我正在测试一个 gpu 但运行三个 tensorflow 实例。
在我的代码中是这样的:
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.3)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))

其他两个 tensorflow 实例运行良好,但只有最后一个运行
像这样的错误:

E tensorflow/stream_executor/cuda/cuda_dnn.cc:371] 无法创建 cudnn
句柄:CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:338] 无法销毁
cudnn 句柄:CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:672] 检查失败:
流->parent()->GetConvolveAlgorithms( conv_parameters.
ShouldIncludeWinogradNonfusedAlgo(), &algorithms)

为什么? gpu 配置是否太小:gpu_options = tf.GPUOptions(per_process_gpu_
memory_fraction=0.3)
我不知道。 想要一些建议。 我会尽力。


你收到这个是因为你被提到了。
直接回复本邮件,在GitHub上查看
https://github.com/tensorflow/tensorflow/issues/6698#issuecomment-352670885
或静音线程
https://github.com/notifications/unsubscribe-auth/AJq-HpINYs1Uae6ghIW3qKCD56SUDhFeks5tB3HZgaJpZM4Lc7S1
.

——
最好的事物
西蒙

SLFWalsh MD MRCP FFRRCSI
[email protected]

就我而言,我在后台运行手电筒时遇到了同样的问题。
我认为...... CUDNN_STATUS_INTERNAL_ERROR 可能发生在其他程序使用 cudnn 时

就我而言,我可以在 ipython 环境中运行 cudnn,但是,当我尝试在 jupyter notebook 中运行代码时,我收到了相同的错误消息

嗨,我遇到了同样的问题,到目前为止,没有任何建议可以帮助我解决它。
我使用的是配备 Windows 10 的华硕 Zenbook Pro 笔记本电脑,其规格如下:

imagen

我的 GPU 规格如下:

imagen

我正在关注本教程:https://www.tensorflow.org/get_started/mnist/pros,您必须在其中实施和训练 1)softmax 回归和 2)具有 MNIST 数据集的多层 CNN。

这些是我的代码: MNIST_Tutorial.zip 。 zip 有 2 个文件:MNIST_softmax_regression.py 和 MNIST_multilayer_CNN.py。

1) 当我运行 MNIST_softmax_regression.py 时,它工作正常:
imagen
如您所见,GPU 正在被使用,根据教程,最终准确率约为 92%。

2) 但是,当我运行 MNIST_multilayer_CNN.py 时,python 崩溃了:
imagen

我根据之前的建议尝试了两种解决方法:

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
with tf.Session(config=config) as sess:

config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.8
with tf.Session(config=config) as sess:

他们都没有工作,虽然第二个产生以下输出:

imagen

如您所见,tensorflow 首先尝试多次分配内存(CUBLAS_STATUS_ALLOC_FAILED),直到它显然成功,但随后出现 CUDNN_STATUS_NOT_INITIALIZED 错误,一切再次失败。

顺便说一句,我根据这些说明末尾的替代方法安装了 tensorflow:http://www.python36.com/install-tensorflow-gpu-windows/
imagen

我使用了这个 CUDA 安装程序:
imagen
imagen

并使用此 .whl 文件安装 tensorflow:
imagen

这里有一些关于 python、pip 和 conda 的更多信息:
imagen

任何帮助将不胜感激。
提前致谢。

你好,
我在两台不同的机器上面临同样的问题:

设置 1:
视窗 10 专业版 64 位
图形处理器信息
CUDA 8.0
卡顿 6.0
TensorFlow 1.4
蟒蛇 3.6.4

设置2:
视窗 10 专业版 64 位
图形处理器信息
CUDA 8.0
cudnn 6.0
TensorFlow 1.4
蟒蛇 3.6.2

任何更新?

与上面的设置非常相似,运行:

窗口 10
图形处理器
张量流 1.5
CUDA 9.0.176
cudnn 7
蟒蛇 3.6.4,蟒蛇

我尝试了配置更改,但仍然收到“CUDNN_STATUS_NOT_INITIALIZED”错误集。

我不确定 .nv 文件夹的等价物在 Windows 上的什么位置,所以我无法运行@SimonWalsh1000解决方案。

@HeinzBenjamin ,成功了吗?

编辑:仍然很难过,可能是因为我在使用 tensorflow 1.5 和 CUDA 9?

我遇到了同样的问题。
但是,我发现安装CUDA 9.0后,我的驱动程序不会是最新版本。
所以,尝试将您的 Nvdia 驱动程序更新到最新版本并重新启动您的 PC。 这个对我有用!

昨天我的代码工作得很好,今天早上 ubuntu 有更新,现在我的代码产生了这个。 其他一切都没有改变。

2018-02-11 07:54:57.097712: E tensorflow/stream_executor/cuda/cuda_dnn.cc:385] 无法创建 cudnn 句柄:CUDNN_STATUS_INTERNAL_ERROR
2018-02-11 07:54:57.097756: E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] 无法销毁 cudnn 句柄:CUDNN_STATUS_BAD_PARAM
2018-02-11 07:54:57.097767: F tensorflow/core/kernels/conv_ops.cc:667] 检查失败:stream->parent()->GetConvolveAlgorithms(conv_parameters.ShouldIncludeWinogradNonfusedAlgo(), &alithms

我已经重新启动系统十几次了。
几次重新启动后,错误更改为

2018-02-11 07:19:33.487404: I tensorflow/stream_executor/cuda/cuda_dnn.cc:393] 驱动程序版本可能不足:384.111.0 2018-02-11 07:19:33:487tensorcuda/stream/executorcuda cuda_dnn.cc:352] 无法破坏 cudnn 句柄:CUDNN_STATUS_BAD_PARAM 2018-02-11 07:19:33.487439: F tensorflow/core/kernels/conv_ops.cc:667] 检查失败:stream->volv()->gorithms() conv_parameters.ShouldIncludeWinogradNonfusedAlgo(), &algorithms)

但升级到 390.25 后,它现在再次产生第一个错误。

我的其他 tensorflow 代码工作正常。

我也尝试删除 nv 目录,但没有效果

ubuntu 17.10,gtx 1060 6GB

我在带有 CUDA 9.0 和 GT 750M 的 Windows 10 上遇到此错误我通过将 GPU 使用率限制为 0.7 来解决它:config.gpu_options.per_process_gpu_memory_fraction = 0.7

正如其他人发布的那样,高于 0.7 的任何内容都会导致 Python 崩溃。

在也收到三位一体的错误后:

CUDNN_STATUS_NOT_INITIALIZED
conv_parameters.ShouldIncludeWinogradNonfusedAlgo(), &algorithms)

尝试了@zzhang68解决方案......在 9.0 安装旧驱动程序后更新驱动程序。
_它奏效了!_

视窗 10 | GTX 980钛
CUDA 9.0 (带有过时的驱动程序!!!!)
\cudnn-9.0-windows10-x64-v7\cuda\bin (cudann64_7.dll) 在 PATH

python 3.6 miniconda
张量流-GPU 1.5.0

面临同样的问题。 tf1.5 py2.7 泰坦 x cuda8。
config.gpu_options.allow_growth = True
不行

我在带有 CUDA 9.0 和 GTX 1060 的 Windows 10 上遇到此错误。
蟒蛇 3.5
张量流-GPU 1.5.0
我找到了一个简单的方法来解决它:将我的 NVIDIA 显示驱动程序更新到最新版本,重新启动 PC
然后它起作用了!

@SimonWalsh1000 ,它真的对我

@stricon@ggranum的解决方案加上驱动程序更新为我解决了这个问题。 我的猜测是,有些人已经定制了电源配置,在需要之前会削弱某些功能。

更新我的 GPU 驱动程序为我解决了这个问题。 我的 GPU 驱动程序是 2017 年 12 月,最新的是 2018 年 2 月 26 日。

您需要拥有正确的 tensorflow、CUDA 版本、cuDNN 版本和 gpu 驱动程序以避免此问题

我的规格:
张量流 1.6
cuDNN v7.0.4(2017 年 11 月 13 日),用于 CUDA 9.0(我必须使用这个版本才能让我的 TF 工作)

这是我修复它的方法。 我同时安装了 CUDA 9.1 和 CUDA 9.0。 和其他人一样,我在安装 CUDA(通过 Geforce Experience 程序)后不得不再次升级我的 GPU 驱动程序。 截至今天,Keras 的后端 TensorFlow 正在使用 CUDA 9.0,因此请确保您已安装。 然后,从https://developer.nvidia.com/rdp/cudnn-download下载 cuDNN 7.0.5(不是最新的 7.1 版本),然后解压并将 bin、include 等文件夹复制到您的 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0 文件夹。 现在它应该可以工作了。

感谢所有这些帮助,在我尝试将我的 cuCNN 从 cnDNN-9.1 降级为 cnDNN-9.0 之后,它工作正常。
我的环境是 Centos7 + CUDA 9.0 + Tensorflow 1.6

在 Python3.5、ubuntu 16.04、tf1.5 上出现同样的错误
将 gpu 驱动程序更新到 390.42 版本为我解决了这个问题。

嗨,大家好,

我刚刚遇到了同样的问题
" E tensorflow/stream_executor/cuda/cuda_dnn.cc:385] 无法创建 cudnn 句柄:CUDNN_STATUS_INTERNAL_ERRORE tensorflow/stream_executor/cuda/cuda_dnn.cc:352] 无法销毁 cudnn 句柄:CUDNN_STATUS_BAD_PARAMF tensorflow/core/kernels/conv_ops.cc:605] 检查失败:stream->parent()->GetConvolveAlgorithms(&algorithms)"

并通过以下方式解决:
1- 更新 NVIDIA Geforce920M 的驱动程序
2- 正确设置 tf 会话如下:
配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
3- 重启电脑

之后,我收到了更精确的错误消息:
“已找到 cuDNN7.1,但应为 cuDNN7.0。升级”

并通过以下方式解决:
我没有升级 rest(tf,cuda,..) 来满足 cuDNN,而是降级了 cuDNN7.0 来满足其余部分。
(将 cuDNN 从 7.1 降级到 7.0.4 )并且效果很好。

我在运行Cnn_Mnist.py 的时候也遇到过这个错误

环境信息:

  • Window10 + tensorflow_gpuV1.6 + cudav9.0, cudnnv7.0 + Python3.5(Anaconda)+ GeForce 920MX
| NVIDIA-SMI 385.54                 Driver Version: 385.54                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce 920MX      WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A   37C    P0    N/A /  N/A |     84MiB /  2048MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     11988      C   ...naconda3\envs\tensorflow_GPU\python.exe N/A      |
+-----------------------------------------------------------------------------+

错误信息:

2018-03-20 13:38:27.439071: E C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\stream_executor\cuda\cuda_dnn.cc:385] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
2018-03-20 13:38:27.443473: E C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\stream_executor\cuda\cuda_dnn.cc:352] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2018-03-20 13:38:27.449591: F C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\kernels\conv_ops.cc:717] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms)

真诚地希望得到大家的帮助:D

在我的情况下(Windows 10),这个问题是由使用错误版本的 cuDNN 引起的。 尽管我严格按照 TensorFlow 的官方说明进行操作,但我不小心下载了 CUDA 9.1 的 7.0.5 版本,而 TF 明确调用了 CUDA 9.0。

一旦我纠正了 cuDNN 错误,我的卷积神经网络就开始工作了 💯 👍 🥇 :)

同样的问题 tf 1.2、cuda 8.0、cudnn 5.1
英伟达更新驱动

好吧,我设法根据 cuda 将 nvidia 驱动程序更新到最新版本,并且它有效。 所以,你可以试试这个方法。

好吧。 它不能很好地工作。 问题又出现了

使用:cudnn-9.0-windows10-x64-v7 和 tensorflow-gpu==1.7.0

教程\图像\图像网> python分类_图像.py
失败并出现错误:无法创建 cudnn 句柄:CUDNN_STATUS_INTERNAL_ERROR

加上上面ggranum的三行代码就解决了问题

对我来说,问题是使用了错误的 cudnn lib
当我有 cuda 9.0 时,我将 cudnn 用于 cuda 9.1。 所以我为 cuda 9.0 重新安装了 cudnn,一切正常。

Win10/Anaconda3/tf-1.3/keras-2.1.3也有同样的问题
将以下代码添加到 .py 文件的开头,解决了我的问题。

from __future__ import print_function, division
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session  
config = tf.ConfigProto()  
config.gpu_options.allow_growth = True  
set_session(tf.Session(config=config)) 

@serans1
这对我有用:)

谢谢@zzhang68 。 您的解决方案对我有用。

在文件的开头添加这个对我有用:

配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

GTX 1070。遇到了这个问题。 我的驱动程序上次更新是在 2017 年。将其更新为最新的驱动程序(2018 年 5 月),重置我的计算机并停止出现问题。 希望这可以帮助

使用@zzhang68解决方案也适用于我。
Ubuntu16.04、tensorflow1.7、nvidia1080、cuda9.0、cudnn7.05。
将驱动程序更新至 390.59 后,问题消失。

win10 使用 tensorflow cpu 的另一种选择...试试

def run_inference_for_single_image(image, graph):
使用 graph.as_default():
配置 = tf.ConfigProto(
device_count = {'GPU':0}
)
使用 tf.Session(config=config) 作为 sess:

@lwd1132438569请问您指的是哪个“最新版本”? 我的 Ubuntu 也遇到了这个问题,我有 python 3.5.2、CUDA 9.0、tensorflow-gpu 1.9.0,驱动程序现在是 390.48。
我想尝试,但恐怕 tensorflow 现在不支持“最新”版本....
谢谢1

@vburca 非常感谢。 我没有意识到拥有另一个 jupyter 笔记本会耗尽 GPU 内存。 非常感谢!!!

我遇到了同样的问题。 我的情况是我降级了 tensorflow 的版本,它适用于我的应用程序。

我发现了同样的问题。 就我而言,这个原因是系统内存不足。 当我运行完其他应用程序时,那个问题就消失了。

2018-09-03 22:50:26.576765: E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] Could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2018-09-03 22:50:26.576831: E tensorflow/stream_executor/cuda/cuda_dnn.cc:360] Possibly insufficient driver version: 390.77.0
[1]    8515 segmentation fault (core dumped)  python3 training.py

GTX1070
CUDA9.0
CUDA9.0 的 CUDNN7.1
TensorFlow 1.10.1
毫无问题地运行像 hello world 这样的简单张量流。
无处知道为什么会发生这种情况.......

肯定是与 cuda 相关的内存问题,杀死所有其他与 cuda 相关的进程并训练/测试你的模型,这应该可以解决问题

@drproy2k解决方案似乎对我也有效。 问题是我正在使用 keras 运行另一个 jupyter notebook 实例,并且我试图在 Pycharm 中运行 keras 训练。 因此,只需关闭 jupyter notebook 并终止此进程即可解决此问题。

[已解决] 在我的情况下,我已经安装了 CUDA v9.2 和相应的 cuDNN,但没有正确安装特定于 tensorflow 所需的 CUDA v9.0 的 cuDNN。

确保您从这里下载正确版本的 cuDNN: https :

不是这里的那个: https :

黄金技巧,重新启动一切,对我有用。

重启也对我有用👍
(但解释为什么会发生这种情况会非常好)

神经网络

我面临同样的问题。 带有卷积层的模型将不起作用。
我为 CUDA 9.0 下载了 cuDNN 7.0 版。 替换文件 cudnn64_7.dll 后,我可以轻松使用convnets。

导致问题的 DLL 版本=> 6.14.11.9020
解决问题的DLL版本=> 6.14.11.9000
Tensorflow GPU 版本=> 1.11.00
CUDA 版本=> 9.0
Python 版本=> 3.5
操作系统=> Windows 10
其他步骤=> 创建 BAT 文件以附加到 PATH 变量,然后使用 /k 选项启动 CMD.EXE
谢谢大家。

我能够通过限制 gpu 使用来让程序运行。 在我在 ubuntu 16.04 上使用 3gb gtx 1060 的情况下,如果我将 gpu 选项 per_process_gpu_memory_fraction 设置为 0.7,它就可以工作。 任何更高的,我都会收到这些错误

E tensorflow/stream_executor/cuda/cuda_dnn.cc:397] 无法创建 cudnn 句柄:CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:364] 无法销毁 cudnn 句柄:CUDNN_STATUS_BAD_PARAM
F tensorflow/core/kernels/conv_ops.cc:605] 检查失败:stream->parent()->GetConvolveAlgorithms(&algorithms)

这可能是 tensorflow 错误报告的一种情况。 似乎完全不相关。 也许这是以更好的方式解决这个问题的线索?

太好了,当我将 gpu_memory_fraction 从 0.8 减少到 0.7 时,它开始工作了!

我在不小心将 tensorflow-gpu从 1.6.0 版本

这是我的问题的解决方案:

https://stackoverflow.com/questions/50622525/which-tensorflow-and-cuda-version-combinations-are-compatible

每当您开始面临此类问题时,在升级 NVIDIA 依赖项之前,始终尝试通过卸载 tensorflow 版本并首先安装与您的 CUDA 依赖项兼容的版本来解决问题。

第 1 步:检查您的 tensorflow 软件包版本。 如果你有 GPU,我建议卸载 tensorflow 的 cpu 版本以避免冲突。

pip list | grep tensorflow

第 2 步:卸载 tensorflow-gpu。

pip uninstall tensorflow

第 3 步:检查您的 CUDA 和 cuDNN 版本。 您可能需要调整这些路径。

-- CUDA
cat /usr/local/cuda/version.txt
如果失败,请使用以下命令找到您的 cuda 版本文本文件:
sudo find / -name version.txt

-- cuDNN
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
如果失败,请使用以下命令找到您的 cuda 版本文本文件:
sudo find / -name cudnn.h

第 4 步:检查您的 tensorflow-gpu、cuda 和 cudnn 版本是否与此表匹配。
image

就我而言,我需要tensorflow-gpu 1.6.0才能满足其他要求。

所以我使用以下方法安装了这个版本:
pip install tensorflow-gpu==1.6.0
这些是有效的规格!

操作系统: Ubuntu 16.04
CUDA 版本: 9.0,V9.0.176
cuDNN 版本: 7.0
Tensorflow-gpu 版本: 1.6.0
Python版本: 3.5.0

祝你好运!

就我而言,当我开始在 VS 代码中运行另一段代码时忘记关闭 jupyter notebook,关闭 jupyter notebook 解决了该问题。

我遇到了同样的问题。
就我而言,我在训练我的网络时运行 Jupyter notebook。
关闭 Jupyter notebook 解决了我的问题。

(我认为它可能必须对我的 GPU 的要求太高)

希望这有帮助!

嗨,伙计们,我遇到了同样的问题。我使用 win10 tensorflow-gpu1.8.0 cuda 9.0 NVIDA gtx1050Ti,当我将 cudann 的版本从 7.0 更改为 7.1 时,问题解决了

我今天遇到了同样的问题(gtx1080,cuda 9.2,tfversion = 1.12.0)。 所以在我的情况下,我正在运行 Jupyter notebook ,然后我尝试运行我的其他脚本,那是引发错误的时候。 解决的是,就像@RoytenBerge所说的,关闭 jupyter 内核。

将这些代码行添加到脚本 @Codersadis 的开头时,它对我有用

将以下代码添加到 .py 文件的开头,解决了我的问题。

从 __future__ 导入 print_function,除法
将张量流导入为 tf
从 keras.backend.tensorflow_backend 导入 set_session
配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
set_session(tf.Session(config=config))

@drproy2k谢谢,它也对我

此错误是由于 RAM 内存问题。 建议您增加 32GB 或 64GB 的 DDR3 或 DDR4 RAM。
还要减少正在推断的数据的数量/大小。

它不是GPU。 我在 SLI 中有 2 X 1080Ti 卡。

我按照版本安装指南来解决这个问题-
https://www.tensorflow.org/install/source#tested_source_configurations。 兼容的配置:-
TF 1.12
TF-GPU 1.9
CUDA 8

与 GeForce GTX 970、CUDNN 7.4.1、CUDA 9.0.176、TF-gpu 1.12.0 相同的问题

在 conda 环境中使用社区支持的 tensorflow 版本时,我遇到了同样的问题(即使用 > conda install tensorflow-gpu )

事实证明,这个版本并不是在所有情况下都很好(即使我一直在其他机器上使用它)。 最好使用的版本是 conda 环境中的 pip 可安装版本https://www.tensorflow.org/install/pip 。 当我这样做时,一切都奏效了。

我没有意识到我在我目前安装的 CUDA 9.0 旁边安装了 CUDNN 库的 Cuda 10.0 版本。 一旦我下载并用 V9.0 CUDNN 替换 V10 CUDNN,一切都运行良好!
这是由于未能正确安装而造成的疏忽,回顾过去,我明白为什么......如果你已经做到了这一点并且厌倦了实验,我已经在https://aaronjencks.blogspot写了一篇博引导您完成使 tensorflow 及其所有依赖项从头到尾工作的整个过程

@kheffah
GPU GT 840M,计算兼容 5.0、CUDA 9、cuDNN 7.4.2、TF 1.12.0。 视窗 8 x64

测试代码运行良好

a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)

这是 spyder 中的错误。 已经尝试了内存 0.7 和增长技巧。 没运气

classifier.fit_generator(training_set,
                    steps_per_epoch=32,
                    epochs=25,
                    verbose=1,
                    validation_data=test_set,
                    validation_steps=6.25)
Epoch 1/25
Traceback (most recent call last):

  File "<ipython-input-4-6d704090deaf>", line 11, in <module>
    validation_steps=6.25)

  File "c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)

  File "c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\engine\training.py", line 1418, in fit_generator
    initial_epoch=initial_epoch)

  File "c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\engine\training_generator.py", line 217, in fit_generator
    class_weight=class_weight)

  File "c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\engine\training.py", line 1217, in train_on_batch
    outputs = self.train_function(ins)

  File "c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\backend\tensorflow_backend.py", line 2715, in __call__
    return self._call(inputs)

  File "c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\backend\tensorflow_backend.py", line 2675, in _call
    fetched = self._callable_fn(*array_vals)

  File "c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\tensorflow\python\client\session.py", line 1439, in __call__
    run_metadata_ptr)

  File "c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 528, in __exit__
    c_api.TF_GetCode(self.status.status))

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 conv2d_1/convolution}} = Conv2D[T=DT_FLOAT, _class=["loc:@training/Adam/gradients/conv2d_1/convolution_grad/Conv2DBackpropFilter"], data_format="NCHW", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](training/Adam/gradients/conv2d_1/convolution_grad/Conv2DBackpropFilter-0-TransposeNHWCToNCHW-LayoutOptimizer, conv2d_1/kernel/read)]]
     [[{{node loss/mul/_91}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_609_loss/mul", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

切换到 tensorflow 1.7

上周四,2019年1月3日,19:29 maxi.wu < [email protected]写道:

@kheffah https://github.com/kheffahconda 中有同样的问题。
已经使用 pip 安装 TF 和 Keras。
GPU GT 840M,计算兼容 5.0、CUDA 9、cuDNN 7.4.2、TF 1.12.0。
视窗 8 x64

测试代码运行良好

a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)

这是 spyder 中的错误。 已经尝试了内存 0.7 和增长技巧。
没运气

分类器.fit_generator(training_set,
step_per_epoch=32,
时代=25,
详细=1,
验证数据=测试集,
验证步骤=6.25)
时代 1/25
回溯(最近一次调用最后一次):

文件 ”",第 11 行,在
验证步骤=6.25)

文件“c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\legacy\interfaces.py”,第 91 行,在包装器中
返回 func( args, * kwargs)

文件“c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\engine\training.py”,第 1418 行,在 fit_generator
initial_epoch=initial_epoch)

文件“c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\engine\training_generator.py”,第 217 行,在 fit_generator
class_weight=class_weight)

文件“c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\engine\training.py”,第 1217 行,train_on_batch
输出 = self.train_function(ins)

文件“c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\backend\tensorflow_backend.py”,第 2715 行,在 __call__
返回 self._call(inputs)

文件“c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\keras\backend\tensorflow_backend.py”,第 2675 行,在 _call
fetched = self._callable_fn(*array_vals)

文件“c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\tensorflow\python\client\session.py”,第 1439 行,在 __call__
run_metadata_ptr)

文件“c:\Users\maxi.wu\AppData\Local\conda\conda\envs\tfgpu\lib\site-packages\tensorflow\python\framework\errors_impl.py”,第 528 行,在 __exit__
c_api.TF_GetCode(self.status.status))

UnknownError:无法获得卷积算法。 这可能是因为 cuDNN 初始化失败,所以尝试查看上面是否打印了警告日志消息。
[[{{node conv2d_1/convolution}} = Conv2D[T=DT_FLOAT, _class=[" loc:@training/Adam/gradients/conv2d_1/convolution_grad/Conv2DBackpropFilter "], data_format="NCHW", dilations=[1, 1 , 1, 1], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/ job:localhost/replica :0/ task:0/device : GPU:0 " ](training/Adam/gradients/conv2d_1/convolution_grad/Conv2DBackpropFilter-0-TransposeNHWCToNCHW-LayoutOptimizer, conv2d_1/kernel/read)]]
[[{{node loss/mul/_91}} = _Recv[client_terminated=false, recv_device="/ job:localhost/replica :0/ task:0/device : CPU:0 ",send_device="/ job:localhost/副本:0/任务:0/设备GPU:0 ”,send_device_incarnation=1,tensor_name="edge_609_loss/mul",tensor_type=DT_FLOAT,_device="/ job:localhost/replica :0/ task:0/deviceCPU :0 "]()]]


您收到此消息是因为您发表了评论。
直接回复本邮件,在GitHub上查看
https://github.com/tensorflow/tensorflow/issues/6698#issuecomment-451079405
或静音线程
https://github.com/notifications/unsubscribe-auth/ABE215xY0OhbFjA_GhVtEIDl_IB4qQGmks5u_b9NgaJpZM4Lc7S1
.

我在win10系统上遇到了同样的问题。 但是发现是内存问题。 杀死另一个正在运行的消耗大量内存资源的应用程序并尝试一下。

我在 Windows 10 NVIDIA GEFORCE GTX 1050 上遇到了类似的问题,一旦我关闭了所有其他正在运行的任务,并按照上面@xhm1014 的建议重试,我的代码就开始像这样运行。 我认为这一定是与内存相关的问题。

肯定和内存有关。 您应该将 RAM 升级到 64GB。

2019 年 1 月 18 日星期五下午 5:30 Samuel Nde [email protected]写道:

我在 Windows 10 NVIDIA GEFORCE GTX 1050 上遇到了类似的问题,很快
因为我关闭了所有其他正在运行的任务,并按照@xhm1014 的建议重试
https://github.com/xhm1014以上,我的代码刚刚开始运行
那。 我认为这一定是与内存相关的问题。


您收到此消息是因为您发表了评论。
直接回复本邮件,在GitHub上查看
https://github.com/tensorflow/tensorflow/issues/6698#issuecomment-455441208
或静音线程
https://github.com/notifications/unsubscribe-auth/ABE217cdDKUuRtdD9jJ_eh2tJWrm2fjeks5vEWnwgaJpZM4Lc7S1
.

我遇到了错误,我通过关闭我的多个 Jupyter 实例并关闭其他应用程序来“修复”它。 我一般不熟悉 tensorflow,所以这可能只解决了我的问题。

E tensorflow/stream_executor/cuda/cuda_dnn.cc:353] 无法创建 cudnn 句柄:CUDNN_STATUS_INTERNAL_ERROR

我在使用 cuda 从源代码编译的 10.1 Cuda+cuDNN7.5 和 TF 1.11 中遇到了这个问题。 我尝试使用的脚本需要在某处插入这些行:
config = tf.ConfigProto() config.gpu_options.allow_growth = True

然后:
sess = tf.Session(graph=detection_graph,config=config)

这样做了,很多“GPU 内存不足错误” - 但是检测进行得非常快,就像我认为在我们使用 GPU 时应该发生的那样。 感谢分享!

我遇到了同样的问题。使用下面的行修复了它。 检查这里获取详细信息。
导出 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64

@EncodeTS我刚刚在我的第一篇文章中添加了一个最小的可重现示例。 你能检查一下它是否在你的机器上重现了这个问题吗? 在我的机器上,一个卷积层有效,但两个卷积层无效,这让我认为问题可能是由某些资源限制引起的。

实际上,我正在使用 Ubuntu 18.04,而不是 macOS,但这看起来是有道理的,它可能是由某些资源限制引起的。 我在 GTX 1050 ti (4 GB) 上遇到了同样的问题,但是当我在 GTX 1080 ti (11 GB) 上运行相同的架构时,问题就消失了。 尽管两个系统之间的所有环境都不相同,但我还是尽力利用了 docker 容器。

This problem is generally related to the version of cuda and GPU memory, if former, the easiest way is to change your cuda version by Anaconda!if later, you can find some ways to solve in other answers.
这个问题一般与显存和cuda版本有关,如果尝试了上面的更改GPU memory的方法无效,考虑更改cuda版本,最简单的方法是不用去管系统装了什么cuda版本,直接在Anaconda中的项目环境下修改cuda版本即可,亲测有效。

如果您仍然遇到此问题,请尝试以下操作。 它对我有用
tf.config.gpu.set_per_process_memory_growth(True); tf.config.gpu.set_per_process_memory_fraction(0.4);

张量流2阿尔法
CUDA 10.0
GTX 1650

我有类似的问题:CUDNN_STATUS_ALLOC_FAILED。
我摔断了头 3-4 个小时。 终于修好了。
这确实有效,正如上面许多人所提到的:
配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)

但关键是把它写在我没有做的

May be tensorflow-gpu version has problems, you should check your own versions try again and again, uninstall and install..... tensorflow-gpu找到对应的版本号然后卸载再重装

将这些代码行添加到脚本 @Codersadis 的开头时,它对我有用

将以下代码添加到 .py 文件的开头,解决了我的问题。

未来进口print_function,部门
将张量流导入为 tf
从 keras.backend.tensorflow_backend 导入 set_session
配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
set_session(tf.Session(config=config))

我在tensorflow-gpu == 1.8.0cudnn version = 7.0.5cuda 9.1.85遇到同样的错误
, ubuntu 16.04即使在我添加了上述建议的解决方案之后。
以下是堆栈跟踪:

INFO - Waveunet Training - Running command 'run'
INFO - Waveunet Training - Started
SCRIPT START
EPOCH: 0
Dataset ready!
Training...
Sep_Vars: 10265550
Num of variables65
2019-07-25 05:10:09.872823: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-07-25 05:10:10.286584: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-07-25 05:10:10.286914: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1356] Found device 0 with properties: 
name: Quadro P4000 major: 6 minor: 1 memoryClockRate(GHz): 1.48
pciBusID: 0000:00:05.0
totalMemory: 7.92GiB freeMemory: 7.83GiB
2019-07-25 05:10:10.286964: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 0
2019-07-25 05:10:10.640890: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-07-25 05:10:10.640952: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929]      0 
2019-07-25 05:10:10.640968: I tensorflow/core/common_runtime/gpu/gpu_device.cc:942] 0:   N 
2019-07-25 05:10:10.641194: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7566 MB memory) -> physical GPU (device: 0, name: Quadro P4000, pci bus id: 0000:00:05.0, compute capability: 6.1)
2019-07-25 05:10:27.643833: I tensorflow/core/kernels/data/shuffle_dataset_op.cc:94] Filling up shuffle buffer (this may take a while): 2054 of 4000
2019-07-25 05:10:35.917445: I tensorflow/core/kernels/data/shuffle_dataset_op.cc:129] Shuffle buffer filled.
2019-07-25 05:10:36.175698: E tensorflow/stream_executor/cuda/cuda_dnn.cc:455] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2019-07-25 05:10:36.175820: E tensorflow/stream_executor/cuda/cuda_dnn.cc:463] possibly insufficient driver version: 384.183.0
2019-07-25 05:10:36.175842: E tensorflow/stream_executor/cuda/cuda_dnn.cc:427] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2019-07-25 05:10:36.175859: F tensorflow/core/kernels/conv_ops.cc:713] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms) 
Aborted (core dumped)

请帮忙

我有类似的问题:CUDNN_STATUS_ALLOC_FAILED。
我摔断了头 3-4 个小时。 终于修好了。
这确实有效,正如上面许多人所提到的:
配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)

但关键是把它写在我没有做的

很好的回复,对我有用!!

将这些代码行添加到脚本 @Codersadis 的开头时,它对我有用
将以下代码添加到 .py 文件的开头,解决了我的问题。
未来进口print_function,部门
将张量流导入为 tf
从 keras.backend.tensorflow_backend 导入 set_session
配置 = tf.ConfigProto()
config.gpu_options.allow_growth = True
set_session(tf.Session(config=config))

我在tensorflow-gpu == 1.8.0cudnn version = 7.0.5cuda 9.1.85遇到同样的错误
, ubuntu 16.04即使在我添加了上述建议的解决方案之后。
以下是堆栈跟踪:

INFO - Waveunet Training - Running command 'run'
INFO - Waveunet Training - Started
SCRIPT START
EPOCH: 0
Dataset ready!
Training...
Sep_Vars: 10265550
Num of variables65
2019-07-25 05:10:09.872823: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-07-25 05:10:10.286584: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-07-25 05:10:10.286914: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1356] Found device 0 with properties: 
name: Quadro P4000 major: 6 minor: 1 memoryClockRate(GHz): 1.48
pciBusID: 0000:00:05.0
totalMemory: 7.92GiB freeMemory: 7.83GiB
2019-07-25 05:10:10.286964: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 0
2019-07-25 05:10:10.640890: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-07-25 05:10:10.640952: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929]      0 
2019-07-25 05:10:10.640968: I tensorflow/core/common_runtime/gpu/gpu_device.cc:942] 0:   N 
2019-07-25 05:10:10.641194: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7566 MB memory) -> physical GPU (device: 0, name: Quadro P4000, pci bus id: 0000:00:05.0, compute capability: 6.1)
2019-07-25 05:10:27.643833: I tensorflow/core/kernels/data/shuffle_dataset_op.cc:94] Filling up shuffle buffer (this may take a while): 2054 of 4000
2019-07-25 05:10:35.917445: I tensorflow/core/kernels/data/shuffle_dataset_op.cc:129] Shuffle buffer filled.
2019-07-25 05:10:36.175698: E tensorflow/stream_executor/cuda/cuda_dnn.cc:455] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2019-07-25 05:10:36.175820: E tensorflow/stream_executor/cuda/cuda_dnn.cc:463] possibly insufficient driver version: 384.183.0
2019-07-25 05:10:36.175842: E tensorflow/stream_executor/cuda/cuda_dnn.cc:427] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2019-07-25 05:10:36.175859: F tensorflow/core/kernels/conv_ops.cc:713] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms) 
Aborted (core dumped)

请帮忙

将 Nvidia 驱动程序更改为 396+ 为我解决了这个问题。

它与可用于加载 GPU 资源以创建 cudnn 句柄的内存部分有关,也称为per_process_gpu_memory_fraction
自己减少这个内存分数将解决错误。

> sess_config = tf.ConfigProto(gpu_options =
> tf.GPUOptions(per_process_gpu_memory_fraction=0.7),
> allow_soft_placement = True)
> 
> with tf.Session(config=sess_config) as sess:
>      sess.run([whatever])

尽可能少地使用你的记忆。 (在代码中,我使用0.7,你可以从0.3甚至更小开始,然后增加直到你得到同样的错误,这就是你的极限。)
将其作为配置传递给您的tf.Session()tf.train.MonitoredTrainingSession()或主管的sv.managed_session()

这应该允许您的 GPU 为您的 TensorFlow 代码创建 cudnn 句柄。

我在 conda 环境中使用 tensorflow 2.0 时出现以下错误。

```2019-12-03 23:48:29.888625: 我tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库cudart64_100.dll
2019-12-03 23:49:06.381259:我tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库nvcuda.dll
2019-12-03 23:49:07.220066:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] 发现设备 0 具有以下属性:
名称:GeForce GTX 1660 Ti 主要:7 次要:5 memoryClockRate(GHz):1.59
pciBusID:0000:01:00.0
2019-12-03 23:49:07.236411:我 tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU 库是静态链接的,跳过 dlopen 检查。
2019-12-03 23:49:07.247476:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] 添加可见的 gpu 设备:0
2019-12-03 23:49:07.256881: I tensorflow/core/platform/cpu_feature_guard.cc:142] 您的 CPU 支持该 TensorFlow 二进制文件未编译使用的指令:AVX2
2019-12-03 23:49:07.269536:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] 发现设备 0 具有以下属性:
名称:GeForce GTX 1660 Ti 主要:7 次要:5 memoryClockRate(GHz):1.59
pciBusID:0000:01:00.0
2019-12-03 23:49:07.281954:我 tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU 库是静态链接的,跳过 dlopen 检查。
2019-12-03 23:49:07.295302: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] 添加可见 gpu 设备:0
2019-12-03 23:49:08.589865: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] 具有强度 1 边缘矩阵的设备互连 StreamExecutor:
2019-12-03 23:49:08.599121:我张量流/核心/common_runtime/gpu/gpu_device.cc:1165] 0
2019-12-03 23:49:08.610543: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N
2019-12-03 23:49:08.616005:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] 创建了 TensorFlow 设备(/job:localhost/replica:0/task:0/device:GPU:0 with 4627 MB 内存)-> 物理 GPU(设备:0,名称:GeForce GTX 1660 Ti,pci 总线 ID:0000:01:00.0,计算能力:7.5)
2019-12-03 23:49:58.521484:我tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库cublas64_100.dll
2019-12-03 23:49:59.604517:我tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库cudnn64_7.dll
2019-12-03 23:50:04.209110: E tensorflow/stream_executor/cuda/cuda_dnn.cc:329] 无法创建 cudnn 句柄:CUDNN_STATUS_NOT_INITIALIZED
2019-12-03 23:50:04.216670: E tensorflow/stream_executor/cuda/cuda_dnn.cc:333] 检索驱动程序版本时出错:未实现:内核报告驱动程序版本未在 Windows 上实现
2019-12-03 23:50:04.226172: E tensorflow/stream_executor/cuda/cuda_dnn.cc:329] 无法创建 cudnn 句柄:CUDNN_STATUS_NOT_INITIALIZED
2019-12-03 23:50:04.234741: E tensorflow/stream_executor/cuda/cuda_dnn.cc:333] 检索驱动程序版本时出错:未实现:内核报告驱动程序版本未在 Windows 上实现
2019-12-03 23:50:04.244958:W tensorflow/core/common_runtime/base_collective_executor.cc:216] BaseCollectiveExecutor::StartAbort 未知:无法获得卷积算法。 这可能是因为 cuDNN 初始化失败,所以尝试查看上面是否打印了警告日志消息。
[[{{节点顺序/conv2d/Conv2D}}]]

so i added the following code to my CNN

gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(GPU[0],真)

My output is now

2019-12-04 00:10:07.708573: 我tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库cudart64_100.dll
2019-12-04 00:10:11.643304: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库 nvcuda.dll
2019-12-04 00:10:12.753615:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] 发现设备 0 具有以下属性:
名称:GeForce GTX 1660 Ti 主要:7 次要:5 memoryClockRate(GHz):1.59
pciBusID:0000:01:00.0
2019-12-04 00:10:12.769498: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU 库是静态链接的,跳过 dlopen 检查。
2019-12-04 00:10:12.783900: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] 添加可见 GPU 设备:0
2019-12-04 00:10:54.941468: I tensorflow/core/platform/cpu_feature_guard.cc:142] 你的 CPU 支持这个 TensorFlow 二进制文件没有被编译使用的指令:AVX2
2019-12-04 00:10:55.372516:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] 发现设备 0 具有以下属性:
名称:GeForce GTX 1660 Ti 主要:7 次要:5 memoryClockRate(GHz):1.59
pciBusID:0000:01:00.0
2019-12-04 00:10:55.383385: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU 库是静态链接的,跳过 dlopen 检查。
2019-12-04 00:10:55.406053: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] 添加可见 gpu 设备:0
2019-12-04 00:10:56.741665: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] 具有强度 1 边缘矩阵的设备互连 StreamExecutor:
2019-12-04 00:10:56.747255:我张量流/核心/common_runtime/gpu/gpu_device.cc:1165] 0
2019-12-04 00:10:56.752302: 我张量流/核心/common_runtime/gpu/gpu_device.cc:1178] 0: N
2019-12-04 00:10:56.756861:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] 创建了 TensorFlow 设备(/job:localhost/replica:0/task:0/device:GPU:0 with 4627 MB 内存)-> 物理 GPU(设备:0,名称:GeForce GTX 1660 Ti,pci 总线 ID:0000:01:00.0,计算能力:7.5)
2019-12-04 00:11:08.281356: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库 cublas64_100.dll
2019-12-04 00:11:08.934804: 我tensorflow/stream_executor/platform/default/dso_loader.cc:44] 成功打开动态库cudnn64_7.dll
2019-12-04 00:11:11.870237:W tensorflow/stream_executor/cuda/redzone_allocator.cc:312] 内部:Windows 不支持调用 ptxas
依赖驱动进行ptx编译。 此消息将只记录一次。
``

正如每个人所建议的那样,这是由于使用所有 GPU/GPU 的 tensorflow。 我的 CNN 现在训练没有错误。

在 conda 环境中使用社区支持的 tensorflow 版本时,我遇到了同样的问题(即使用 > conda install tensorflow-gpu )

事实证明,这个版本并不是在所有情况下都很好(即使我一直在其他机器上使用它)。 最好使用的版本是 conda 环境中的 pip 可安装版本https://www.tensorflow.org/install/pip 。 当我这样做时,一切都奏效了。

为我解决了,谢谢!

这也为我解决了这个问题。

GeForce GTX 1050、CUDA 10.0

注意:这是我目前唯一能在 TF 2.0 中找到的东西。 谢谢!

gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(GPU[0],真)

这也为我解决了这个问题。

GeForce GTX 1050、CUDA 10.0

注意:这是我目前唯一能在 TF 2.0 中找到的东西。 谢谢!

gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(GPU[0],真)

这对我没有任何影响... TF 2.0、RTX 2060、CUDA 10.1、CuDNN 7.6

这是具有 16 GB RAM、6 GB 视频内存和一个带有一个卷积层的基本 MNIST 玩具模型。 没有内存问题,只是一个堆栈跟踪。

像往常一样,Pytorch 完全没有 GPU 问题

就我而言,我有两台机器,都是 RTX 2080Ti、TF 2.1、CUDA 10.1、CuDNN 7.6。 一个有效,另一个引发上述错误。 两台机器都有相同数量的 RAM,16GB。 但是,有硬件差异,例如 CPU。 但问题仅在使用 GPU 时发生。

就我而言,我有两台机器,都是 RTX 2080Ti、TF 2.1、CUDA 10.1、CuDNN 7.6。 一个有效,另一个引发上述错误。 两台机器都有相同数量的 RAM,16GB。 但是,有硬件差异,例如 CPU。 但问题仅在使用 GPU 时发生。

同样的平台,同样的问题

如果您使用的是最新的 tensorflow 和 keras。 从这里尝试这个,它对我有用:

gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
  try:
    # Currently, memory growth needs to be the same across GPUs
    for gpu in gpus:
      tf.config.experimental.set_memory_growth(gpu, True)
    logical_gpus = tf.config.experimental.list_logical_devices('GPU')
    print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
  except RuntimeError as e:
    # Memory growth must be set before GPUs have been initialized
    print(e)

这个对我有用。
physical_devices = tf.config.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(物理设备[0],真)

这个对我有用。
physical_devices = tf.config.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(物理设备[0],真)

这对我有用。 谢谢

@Samaritan1011001非常感谢您的解决方案对我有用。

此页面是否有帮助?
0 / 5 - 0 等级