Tag Archives: Pytorch call tensorboard error

[Solved] Pytorch call tensorboard error: AttributeError: module ‘tensorflow’ has no attribute ‘gfile’

Problem description

An error occurs when executing the following command:

from torch.utils.tensorboard import SummaryWriter

tb_writer = SummaryWriter(osp.join(opt.savepath, "logdir"))

Error content:

AttributeError: module 'tensorflow._api.v1.io' has no attribute 'gfile'

Problem analysis

The root cause of this problem is that pytorch has adjusted tensorflow. Finally, tensorflow reports an error. The new version of tensorflow is incompatible with the old version.

After checking, my pytorch version is 1.6, tensorboard version is 1.15.0, and tensorflow version is 1.12.0

Problem-solving:

Upgrade the tensorflow version to version 2.0. Executing the following command will automatically upgrade the tensorflow version and tensorboard version:

pip install tensorflow==2.0

End.