【问题标题】:TensorFlow Nvidia 1070 GPU memory allocation errors how to troubleshoot?TensorFlow Nvidia 1070 GPU内存分配错误如何排查?
【发布时间】:2017-04-22 22:25:27
【问题描述】:

远射: 搭载 8Gig 的 Ubuntu 16.04 Nvidia 1070?机器有 64 Gig ram,数据集是 100 万条记录和当前 cuda、cdnn 库、TensorFlow 1.0 Python 3.6

不确定如何排除故障?

我一直在努力使用 TensorFlow 构建一些模型,并且多次遇到这种现象:除了使用 GPU 内存的 TensorFlow,我不知道还有什么?

I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: name: GeForce GTX 1070 major: 6 minor: 1 memoryClockRate (GHz) 1.645 pciBusID 0000:01:00.0 Total memory: 7.92GiB Free memory: 7.56GiB 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 1070, pci bus id: 0000:01:00.0) E tensorflow/stream_executor/cuda/cuda_driver.cc:1002] failed to allocate 7.92G (8499298304 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY E tensorflow/stream_executor/cuda/cuda_driver.cc:1002] failed to allocate 1.50G (1614867456 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY E tensorflow/stream_executor/cuda/cuda_driver.cc:1002] failed to allocate 1.50G (1614867456 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY E tensorflow/stream_executor/cuda/cu

我得到以下信息,这表明正在进行某种内存分配?但仍然失败。

`I tensorflow/core/common_runtime/bfc_allocator.cc:696] 5 Chunks of size 899200000 totalling 4.19GiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 1649756928 totalling 1.54GiB
I tensorflow/core/common_runtime/bfc_allocator.cc:700] Sum Total of in-use chunks: 6.40GiB
I tensorflow/core/common_runtime/bfc_allocator.cc:702] Stats: 
Limit:                  8499298304
InUse:                  6875780608
MaxInUse:               6878976000
NumAllocs:                     338
MaxAllocSize:           1649756928

W tensorflow/core/common_runtime/bfc_allocator.cc:274] ******************************************************************************************xxxxxxxxxx
W tensorflow/core/common_runtime/bfc_allocator.cc:275] Ran out of memory trying to allocate 6.10MiB.  See logs for memory state.
W tensorflow/core/framework/op_kernel.cc:993] Internal: Dst tensor is not initialized.
     [[Node: linear/linear/marital_status/marital_status_weights/embedding_lookup_sparse/strided_slice/_1055 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_1643_linear/linear/marital_status/marital_status_weights/embedding_lookup_sparse/strided_slice", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/gpu:0"]()]]

` 更新:我将记录数从数百万减少到 40,000,并让一个基本模型运行完成。我仍然收到一条错误消息,但不是连续的。我在模型输出中得到一堆文本,建议重构模型,我怀疑数据结构是问题的很大一部分。仍然可以使用一些更好的提示来调试整个过程。以下是剩余的控制台输出

I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:910] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
name: GeForce GTX 1070
major: 6 minor: 1 memoryClockRate (GHz) 1.645
pciBusID 0000:01:00.0
Total memory: 7.92GiB
Free memory: 7.52GiB
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 1070, pci bus id: 0000:01:00.0)
E tensorflow/stream_executor/cuda/cuda_driver.cc:1002] failed to allocate 7.92G (8499298304 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
[I 09:13:09.297 NotebookApp] Saving file at /Documents/InfluenceH/Working_copies/Cond_fcast_wkg/TensorFlow+DNNLinearCombinedClassifier+for+Influence.ipynb
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0)

【问题讨论】:

标签: tensorflow gpu


【解决方案1】:

我认为问题在于 TensorFlow 尝试分配 7.92GB 的 GPU 内存,而实际上只有 7.56GB 是空闲的。我不能告诉你剩余的 GPU 内存被占用的原因是什么,但你可以通过限制你的程序允许分配的 GPU 内存的比例来避免这个问题:

sess_config = tf.ConfigProto()
sess_config.gpu_options.per_process_gpu_memory_fraction = 0.9
with tf.Session(config=sess_config, ...) as ...:

这样,程序将只分配 90% 的 GPU 内存,即 7.13GB。

【讨论】:

  • 没有得到应该在最后一行中代替 ... 的内容?另请参阅我的更新...
  • 括号之间的圆点可以替换为您希望用来初始化 tf.Session() 的其他选项。这些选项应该是您可能已经指定的选项(如果有的话)。如果您没有任何进一步的规范,请删除逗号和点。在 ":" 之前定义调用 tf.Session() 的名称,例如 with tf.Session(config=sess_config) as sess:
  • 帮了大忙!我认为仍然需要重组模型.. 但克服了最初的错误
  • 您是否将百万数据样本的完整“记录计数”加载到 GPU 内存中。如果是这样,这可能是您的记忆问题的原因。在这种情况下,可能需要减少您的记录数(如您已经描述的那样)或实现从文件中读取某种顺序数据,以便使用完整的数据集进行训练。
猜你喜欢
  • 2017-11-13
  • 1970-01-01
  • 2016-03-15
  • 1970-01-01
  • 1970-01-01
  • 2019-08-29
  • 1970-01-01
相关资源
最近更新 更多