TensorFlow程序中的内存泄漏

时间:2016-09-26 14:14:35

标签: python memory-leaks tensorflow

我的程序遭遇内存泄漏,我无法弄清楚原因。以下是mem_top在累积3 GB不必要内存后获得的一些内存统计信息:

refs:
28226   <class 'dict'> {1: <tensorflow.python.framework.ops.Operation object at 0x7fa4cc149550>, 2: <tensorflow.python.fram
14113   <class 'dict'> {'Const_4136': <tensorflow.python.framework.ops.Operation object at 0x7fa3ad179550>, 'rnn/map_1/whil
5575    <class 'list'> ['# module pyparsing.py\n', '#\n', '# Copyright (c) 2003-2015  Paul T. McGuire\n', '#\n', '# Permiss
4095    <class 'list'> ['# Copyright 2015 The TensorFlow Authors. All Rights Reserved.\n', '#\n', '# Licensed under the Apa
3592    <class 'set'> {<tensorflow.python.framework.ops.Operation object at 0x7fa448620048>, <tensorflow.python.framework.
2770    <class 'list'> ['# Copyright 2015 The TensorFlow Authors. All Rights Reserved.\n', '#\n', '# Licensed under the Apa
2468    <class 'list'> ['# Copyright 2015 The TensorFlow Authors. All Rights Reserved.\n', '#\n', '# Licensed under the Apa
2010    <class 'list'> ['# Copyright 2015 The TensorFlow Authors. All Rights Reserved.\n', '#\n', '# Licensed under the Apa
1912    <class 'list'> ['# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\n', '#\n', '# Licensed under the Apa
1882    <class 'dict'> {9914368: <weakref at 0x7fa585dc4548; to 'type' at 0x974800 (managedbuffer)>, 140348670317568: <weak

types:
246109   <class 'dict'>
207253   <class 'tuple'>
149516   <class 'list'>
69645    <class 'weakproxy'>
69050    <class 'google.protobuf.internal.python_message._Listener'>
32579    <class 'function'>
31374    <class 'tensorflow.core.framework.attr_value_pb2.AttrValue'>
25638    <class 'google.protobuf.internal.containers.RepeatedScalarFieldContainer'>
14230    <class 'tensorflow.python.framework.ops.Tensor'>
14183    <class 'google.protobuf.internal.message_listener.NullMessageListener'>

我能想到的唯一特殊事情是我在tf.Session.run的提取内部有三元运算符,如下所示:

run([my_op if not my_flag else tf.constant(0.0), ..], ..)

但它可能与此完全无关。似乎每个训练步骤增加了大约6个dict个实例。

知道可能导致这种情况的原因吗?

0 个答案:

没有答案
相关问题