I am trying to use tensorboard on colab. I manage to make it work, but not for all commands. add_graph and add_scalar works, but when I tried to run add_embedding I am getting the following error:
AttributeError: module 'tensorflow._api.v1.io.gfile' has no attribute 'get_filesystem'
This is the relevant code (I think);
import os
from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter(log_dir ="logs" )
images, labels = select_n_random(trainset.data, trainset.targets)
images = torch.from_numpy(images)
labels = torch.from_numpy(np.array(labels))
class_labels = [classes[lab] for lab in labels]
# log embeddings
features = images.reshape((-1,32*32*3))
writer.add_embedding(features,metadata=class_labels) #, label_img=images.unsqueeze(1))
The complete error is:
/tensorflow-1.15.0/python3.6/tensorflow_core/python/util/module_wrapper.py in __getattr__(self, name)
191 def __getattr__(self, name):
192 try:
--> 193 attr = getattr(self._tfmw_wrapped_module, name)
194 except AttributeError:
195 if not self._tfmw_public_apis:
AttributeError: module 'tensorflow._api.v1.io.gfile' has no attribute 'get_filesystem'
using
I also tried using the "magic" command:
%load_ext tensorboard
%tensorboard --logdir logs
But I wasn't able to make it work that way (other issues).
Any suggestions how can I make it work?
For me, this fixed the problem:
import tensorflow as tf
import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile
Uninstall the tensorflow. Do not install tensorflow with torch in the same environment. If you install tensorflow, tensorboard may try to use the api of tensorflow firstly.
Then you may encounter this problem: 'LocalFileSystem' object has no attribute 'makedirs'.
There is a solution - https://github.com/pytorch/pytorch/issues/34028
tensorboard 2.2.0 and torch 1.14.0 is worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With