Closed
Description
Describe the current behavior
The RunOptions report_tensor_allocations_upon_oom and embedding_lookup will lead to CPU memory leak.
This will only happen in tf 1.12, tf 1.10 didn't have this problem.
I thought tf.gather
have almost same functionality, so I test it and it seems no problem at all.
I'm not sure if #21348 is related to this problem. My problem will only occur with runoptions.
Code to reproduce the issue
import tensorflow as tf
embeddings = tf.reshape(tf.range(1000), shape=(100,10))
ids = tf.reshape(tf.range(100), shape=(20,5))
embedding_lookup = tf.nn.embedding_lookup(embeddings, ids)
ga = tf.gather(embeddings, ids)
with tf.Session() as sess:
sess.graph.finalize()
run_opts = tf.RunOptions(report_tensor_allocations_upon_oom=True)
for i in range(10000000):
sess.run(embedding_lookup, options=run_opts)
#sess.run(ga, options=run_opts)
The code above leaks cpu memory quite rapidly ~3 Mb/s.
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): v1.12.0-0-ga6d8ffae09 1.12.0
- Python version: 3.6.7
- Bazel version (if compiling from source): N/A
- GCC/Compiler version (if compiling from source): N/A
- CUDA/cuDNN version: 9.0/ 7.4.2
- GPU model and memory: GTX 1070 with 8GB memory