You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ram memory leak when using tf.function at tf 2.8,2.9 and 2.10, doesn't happen with tf 2.5 #57982
Every time I use a tf.function decorator there is a memory leak in the ram, that keeps growing every iteration, I observed this in ubuntu and windows, it didn't happen with tf 2.5 but I had the server updated to python 3.10 and all the version compatible with python 3.10 (tf 2.8,2.9,2.10) have this issue. I tried with python 3.9 in my personal device and the issue still occurs. The leak is small but in an RL setting this is a critical issue in RL since we have to call a tf.function to take actions in the environment millions of times during training and without the decorator things go like 10 times slower.Note that it is not an issue about not passing tensorflow objects to the wrapper, neither about having the shape of the tensor changing.Please I need this to be fixed as soon as possible.
Standalone code to reproduce the issue
import tensorflow as tf
@tf.function
def operate(img):
return img
img = tf.zeros((6,6,7))foriin range (100000000):
s= operate(img)
Relevant log output
just monitor the ram, you will see it growing constantly if you are using tf>=2.8 with tf 2.5.0 ram remains constant for the code above
Hi @sampathrajapaksha the only solution I got is to have an script where I periodically save all training data, close everything and restart training. Sadly as you see here there has been no word about a proper fix yet.
@bgLeon Yes, that's one possible solution which I also thought about. I saw a few people have posted the same issue in StackOverflow and, unfortunately couldn't find any efficient solution yet
Activity
tilakrayal commentedon Oct 6, 2022
@sachinprasadhs,
I was able to reproduce the issue on tensorflow v2.8, v2.10 and nightly. Kindly find the gist of it here.
bgLeon commentedon Dec 16, 2022
Any updates on this?
sampathrajapaksha commentedon Mar 8, 2023
@bgLeon Did you find the solution for this?
i have the same issue and couldn't find a proper solution yet
bgLeon commentedon Mar 8, 2023
Hi @sampathrajapaksha the only solution I got is to have an script where I periodically save all training data, close everything and restart training. Sadly as you see here there has been no word about a proper fix yet.
sampathrajapaksha commentedon Mar 8, 2023
@bgLeon Yes, that's one possible solution which I also thought about. I saw a few people have posted the same issue in StackOverflow and, unfortunately couldn't find any efficient solution yet
bgLeon commentedon Mar 8, 2023
@sampathrajapaksha could you share the stackoverflow link? might happen that someone posts there useful insights
tnybny commentedon Apr 17, 2023
reproducible with 2.11. Possible duplicate of #50765.
chrisyeh96 commentedon Jan 19, 2024
This issue seems to be fixed for me, as of TF 2.14
output:
sachinprasadhs commentedon Jan 19, 2024
@chrisyeh96 , Thanks for validating.
@bgLeon , Even I was able to see the constant memory when I ran your code, could you please verify and close the issue.
bgLeon commentedon Jan 20, 2024
Wow it took a while, yes I tested with TF 2.14 and I don't see the error anymore either, it's solved in this version
google-ml-butler commentedon Jan 20, 2024
Are you satisfied with the resolution of your issue?
Yes
No