Tensorboard is always showing old data

I have a code that’s supposed to show a simple line on Tensorboard.

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)

But for some reason, my tensorboard is not updating. It only shows the data that I did previously.


Currently the only way I update/refresh my tensorboard is by restarting my PC. Any other solutions? Thank you!

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

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.

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

Just tried playing with flush_secs and flush(), the problem is still there

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=2)
logger.add_scalar(‘first/some_number’, 0, global_step=1)
logger.add_scalar(‘first/some_number’, 1, global_step=2)

logger.flush()
out: C:\Users\xxxx\AppData\Local\Temp\tmp9fkkzqlb

Ignore the no data part. The directory is still showing the old one.

Please let me know if there are more methods I could try. Thank you!