Unbounded Memory leak when using tf.py_function in tf.data.Dataset.map() #61344
Labels
stat:awaiting tensorflower
Status - Awaiting response from tensorflower
TF 2.13
For issues related to Tensorflow 2.13
type:bug
Bug
type:performance
Performance Issue
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
No
Source
binary
TensorFlow version
v2.13.0-rc2-7-g1cb1a030a62 2.13.0
Custom code
Yes
OS platform and distribution
Linux Ubuntu 20.04, Google Colab
Mobile device
No response
Python version
3.8
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
11.8 / 8.6
GPU model and memory
various, e.g. 2080ti, 3080ti mobile, Colab T4
Current behavior?
Using tf.py_function in a function that is applied to a tf.data.Dataset via its map() function causes a (C++-level) memory leak.
In my real training with more complex code inside the py_function, this lead to the python script eventually consuming upwards of 30 GB of RAM during a model.fit() loop, despite taking less that 3GB of RAM during the initial epoch.
tf.py_function also more generally causes memory leaks in all kinds of places. See the flags at the top of the linked Collab for details.
Standalone code to reproduce the issue
Relevant log output
The text was updated successfully, but these errors were encountered: