TensorFlow程序内存泄漏

2024-06-12 03:53:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我的程序内存泄漏,我不太明白原因。以下是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的fetch中有三元运算符,如下所示:

^{pr2}$

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

知道是什么原因造成的吗?在


Tags: thetensorflowframeworkallauthorsdictatlist