What are the requirements for the log_dir to work in tensorboard + Pytorch?

I had:

    tb = SummaryWriter()
    args.tb = tb

but nothing appeared when I had

tb.add_scalar('loss', loss, i)

Why?

Do I have to have the folder defined before hand? Or does tensorboard create the folders by itself if they need to be created?


Follow up, where is the dir?

Ok the docs say:

log_dir (string) – Save directory location. Default is runs/CURRENT_DATETIME_HOSTNAME, which changes after each run. Use hierarchical folder structure to compare between runs easily. e.g. pass in ‘runs/exp1’, ‘runs/exp2’, etc. for each new experiment to compare across them

but its not here:

cd /runs
cd: no such file or directory: /runs

Did you start tensorboard backend? Try to open cmd in the same directory as your project and type:

tensorboard --logdir=runs

Or in Jupyter you can run a cell with the following command:

%load_ext tensorboard # this loads tensorboard backend
%tensorboard --logdir runs

Also you don’t need args.tb = tb in your code.