tensorboardX icon indicating copy to clipboard operation
tensorboardX copied to clipboard

AttributeError: 'NoneType' object has no attribute 'get_logdir'

Open ranshuo-ICer opened this issue 2 years ago • 3 comments

Describe the bug When I was using tensorboardX in pytorch to record hyper parameters, I got the error as the title described.

Minimal runnable code to reproduce the behavior

import tensorboardX
writer = tensorboardX.SummaryWriter()
hparams = {'batch_size': args.batch_size,
           'lr': args.lr,
           'momentum': args.momentum,
           'weight_decay': args.weight_decay}
writer.add_hparams(hparams, {'best_acc1': best_acc1})
...

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

Environment What is the result of

protobuf 3.19.6 tensorboard 2.10.1 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.1 tensorboardX 2.2 torch 1.11.0 torch-tb-profiler 0.4.0 torchaudio 0.11.0 torchvision 0.12.0

Python environment Which version of python are you using? Did you use Andconda or Virtualenv? Andconda Additional context Add any other context about the problem here.

ranshuo-ICer avatar Nov 01 '22 14:11 ranshuo-ICer

Hi, I can't reproduce with tensorboardX 2.2. image

Do you have more information?

lanpa avatar Nov 06 '22 12:11 lanpa

OK, I found the question. i called writer.close() every epochs to refresh the output file. Changing the code like this, i reproduce the bug: image

ranshuo-ICer avatar Nov 06 '22 12:11 ranshuo-ICer

Hi, because the writer was closed and followed by another write operation. We should have a warning for this. Thanks for pointing out!

lanpa avatar Dec 11 '22 14:12 lanpa