New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak: tf1 trained saved_model in tf2 for prediction #10759
Comments
I encountered the same memory leak. I also tried the same steps as you. Memory leak for saved model, for frozen inference graph. Doesn't matter whether it's in eager mode or graph mode, the memory leak is always there. |
When disabling the GPU, the memory leak disappears. try:
# Disable all GPUS
tf.config.set_visible_devices([], 'GPU')
visible_devices = tf.config.get_visible_devices()
for device in visible_devices:
assert device.device_type != 'GPU'
except:
# Invalid device or cannot modify virtual devices once initialized.
pass Cuda version is 11.2 and cudnn 8100, tensorflow is 2.7.1. But it also occurs with the newest tensorflow. |
Well, it "helps" but then the model doesn't run on the GPU anymore... So it's certainly not a fix/workaround. |
This is a memory leak of CPU memory, not GPU memory. It also occurs when disabling the GPU altogether. |
Prerequisites
Please answer the following questions for yourself before submitting an issue.
1. The entire URL of the file you are using
https://github.com/tensorflow/models/tree/master/official/...
2. Describe the bug
A clear and concise description of what the bug is.
I have previously trained ssd_inception_v2 model in tensorflow 1.14. It has frozen_inference graph and saved_model dir with protobuf files and variables. I am running tensorflow 2.6.0. loading tf 1.14 trained saved_model into tf 2.6 is done without problem and it runs smoothly. But over the period of time, cpu memory keeps increasing and after some time, prediction scrip crashes because of memory full. I have tried to load "frozen graph.pb" instead of saved_model.pb and problem still exists. Any help would be appreciated. Using "htop" command, MEM% column keep increasing over the time with follwing script running.
3. Steps to reproduce
Steps to reproduce the behavior.
Any tensorflow 1 trained model with saved_model dir after training.
sample: wget http://download.tensorflow.org/models/object_detection/ssd_inception_v2_coco_2018_01_28.tar.gz
use saved_model dir.
I have tested same code with tensorflow 2.9.0 and problem still exists.
4. Expected behavior
A clear and concise description of what you expected to happen.
Memory consumption should be constant.
5. Additional context
Include any logs that would be helpful to diagnose the problem.
6. System information
The text was updated successfully, but these errors were encountered: