Tensorboard is always showing old data

Coca_Cola12: <p>I have a code that’s supposed to show a simple line on Tensorboard.</p>
<pre><code class="lang-auto">import torch.utils.tensorboard as tb
import tempfile
log_dir = tempfile.mkdtemp()
print(log_dir)
%tensorboard --logdir {log_dir}

logger = tb.SummaryWriter(log_dir+'/test3', flush_secs=1)
logger.add_scalar('first/some_number', 0, global_step=1)
logger.add_scalar('first/some_number', 1, global_step=2)
</code></pre>
<p>But for some reason, my tensorboard is not updating. It only shows the data that I did previously.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/7/87667391747928451a1ee46a45f0adbceb4113a7.png" data-download-href="https://discuss.pytorch.org/uploads/default/87667391747928451a1ee46a45f0adbceb4113a7" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/7/87667391747928451a1ee46a45f0adbceb4113a7_2_690x279.png" alt="image" data-base62-sha1="jjNXv6uHS76YbZWASunukEBuEf5" width="690" height="279" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/7/87667391747928451a1ee46a45f0adbceb4113a7_2_690x279.png, https://discuss.pytorch.org/uploads/default/optimized/3X/8/7/87667391747928451a1ee46a45f0adbceb4113a7_2_1035x418.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/8/7/87667391747928451a1ee46a45f0adbceb4113a7_2_1380x558.png 2x" data-dominant-color="4C4139"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1498×607 58.6 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
Currently the only way I update/refresh my tensorboard is by restarting my PC. Any other solutions? Thank you!</p>

ptrblck: <p>Restarting your PC to get an update in <code>tensorboard</code> sounds quite annoying. Are you able to just reload the page to see the updates or in the worst case restart the <code>tensorboard</code> instance?</p>

Coca_Cola12: <aside class="quote no-group" data-username="ptrblck" data-post="2" data-topic="161169">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>Are you able to just reload the page to see the updates or in the worst case restart the <code>tensorboard</code> instance?</p>
</blockquote>
</aside>
<p>Hello, reload the page doesn’t do anything. How do I restart tensorboard instance? I’m running the tensorboard from PyCharm terminal or Jupyter Notebobok. The only way for me to quit on pycharm is CTRL + C. But after CTRL + C and making a new tensorboard, the very old one still shows up.</p>

orionr: <p>I’m wondering if this might have something to do with buffering within the TensorBoard logging itself? Try playing with <code>flush_secs</code> or call <code>flush()</code> manually and see if that helps.</p>

Coca_Cola12: <aside class="quote no-group" data-username="orionr" data-post="4" data-topic="161169">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/orionr/48/4543_2.png" class="avatar"> orionr:</div>
<blockquote>
<p><code>flush()</code></p>
</blockquote>
</aside>
<p>Just tried playing with flush_secs and flush(), the problem is still there</p>
<blockquote>
<p>import torch.utils.tensorboard as tb<br>
import tempfile<br>
log_dir = tempfile.mkdtemp()<br>
print(log_dir)<br>
%tensorboard --logdir {log_dir}</p>
<p>logger = tb.SummaryWriter(log_dir+‘/test3’, flush_secs=2)<br>
logger.add_scalar(‘first/some_number’, 0, global_step=1)<br>
logger.add_scalar(‘first/some_number’, 1, global_step=2)</p>
<p>logger.flush()<br>
out: C:\Users\xxxx\AppData\Local\Temp\tmp9fkkzqlb</p>
</blockquote>
<p>Ignore the no data part. The directory is still showing the old one.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/8/f847744bcf9dce51b9d75ed04c22d205e5249ffc.png" data-download-href="https://discuss.pytorch.org/uploads/default/f847744bcf9dce51b9d75ed04c22d205e5249ffc" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/f/8/f847744bcf9dce51b9d75ed04c22d205e5249ffc.png" alt="image" data-base62-sha1="zqnvaCKr4lQMZbZhsFYlhYHYeQs" width="690" height="445" data-dominant-color="3D3D3D"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">770×497 47.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

Coca_Cola12: <p>Please let me know if there are more methods I could try. Thank you!</p>