I have a very simple TensorFlow graph that I initialize over and over again in a for loop using sess.run(tf.global_variables_initializer()).
I noticed that it takes longer and longer to initialize the variables as the iteration progresses. I haven't noticed any memory leak.
Below is a fully reproducible code tested on Linux (CPU + GPU) and MacOS with TensorFlow 1.13.1, 1.14.0 as well as 1.15.2:
import tensorflow as tf
import matplotlib.pyplot as plt
import time
from tqdm import tqdm
w = tf.get_variable('w', shape=(100, 1000))
sess = tf.Session()
times = []
for i in tqdm(range(2000)):
s = time.time()
sess.run(tf.global_variables_initializer())
times.append(time.time() - s)
plt.plot(times)
plt.xlabel('iteration')
plt.ylabel('time (s)')
plt.title('Evolution of time per step')
