Reputation: 1496
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?
Upvotes: 8
Views: 11787
Reputation: 340
Solution 1:
It does slow down program execution by a huge factor.
import tensorflow as tf
import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile
Solution 2:
If you created a virtualenv to use pytorch, you have to make sure that you only installed pytorch
and tensorboard
, but not tensorflow
, as it has conflicts with the others. Removing tensorflow from the vritualenv containing pytorch and tensorboard solves the problem.
If you did not create a virtualenv and installed everything in the same spot, either
Uninstalling tensorflow will remove the %tensorboard
magic, so you need to keep it if you're using tensorboard
inline in a jupyter cell.
So, solution 1 made more sense in my case.
Upvotes: 0
Reputation: 11444
For me, this fixed the problem:
import tensorflow as tf
import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile
Upvotes: 22
Reputation: 21
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.
Upvotes: 2