I'm encountering an issue while trying to utilize torch.utils.tensorboard.SummaryWriter with PyTorch. I'm training a DCGAN in torch and despite not directly importing or using TensorFlow in my code, I receive the following error:
Traceback (most recent call last):
File "C:/Users/Gebruiker/PycharmProjects/BobRossGAN/train.py", line 47, in <module>
writer_real = SummaryWriter(f"logs/real")
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\utils\tensorboard\writer.py", line 247, in __init__
self._get_file_writer()
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\utils\tensorboard\writer.py", line 277, in _get_file_writer
self.file_writer = FileWriter(
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\utils\tensorboard\writer.py", line 76, in __init__
self.event_writer = EventFileWriter(
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorboard\summary\writer\event_file_writer.py", line 73, in __init__
if not tf.io.gfile.exists(logdir):
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorboard\lazy.py", line 65, in __getattr__
return getattr(load_once(self), attr_name)
AttributeError: module 'tensorflow' has no attribute 'io'
Here's a snippet of my code:
import torch
from torch.utils.tensorboard import SummaryWriter
# other imports and code
writer_real = SummaryWriter(f"logs/real")
I can post my full code, but the error gets thrown on the SummaryWriter initialization.
I'm not sure why this error keeps persisting, I have tried downgrading to lower versions of pytorch, tensorflow and tensorboard, without much success. I've seen answers to similar questions include downgrading tensorboard to 1.15, but this also does not work for me.
Does anyone know how to address this error?
I'm using torch==2.2.0 and tensorboard==2.13.0.