Tensorflow Cuda错误无法获取设备0的设备属性13



我在使用tensorflow keras训练神经网络时遇到了问题。我得到这个错误:

F tensorflow/stream_executor/lib/statursor.cc:34]正在尝试获取值而不是处理错误内部:无法获取设备设备0的属性13:CUDA_ERROR_UNKNOWN:未知错误

我最初收到这个错误。然后我参考了failed-to-get-device-attribute-13-for-vice-0中的解决方案。我更新了图形驱动程序。这在3-4次跑步中起到了作用,现在我又犯了同样的错误。

以下是我的环境细节:

  1. Python 3.7(Anaconda(
  2. Tensorflow 2.1
  3. Nvidia GeForce RTX 2060,6GB显卡
  4. Windows 10版本1809

在我的情况下,限制GPU内存是有效的。

在代码的开头添加以下代码段:

import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(gpus[0], True)

我在向cuda发送tf模型时遇到了这个错误。我的错误在使用时得到了解决。

with tf.device("/gpu:0"):

代替

with tf.device("cuda"):

因此,不使用cuda,而是像这样指定it/gpu:0。如果你有多个GPU,只需从文档中检查tensorflow的正确安装。

安装后,在tf导入后添加此

mirrored_strategy = tensorflow.distribute.MirroredStrategy()

&它应该自动检测多个GPU的

最新更新