Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tensorboard colab tensorflow._api.v1.io.gfile' has no attribute 'get_filesystem

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

  • tensorflow-1.15.0 (tried to install 2.0 but had different issues)
  • Python 3.6.9
  • torch 1.4.0
  • tensorboard 2.1.1 (tried also with 1.15.0 but same issue)

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?

like image 390
justadev Avatar asked Mar 17 '20 21:03

justadev


Video Answer


2 Answers

For me, this fixed the problem:

import tensorflow as tf
import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile
like image 156
Jjang Avatar answered Jan 22 '23 14:01

Jjang


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

  • Uninstalled tensorflow
  • Reinstalled Tensorboard
    PS: Restart Kernel and tensorboard.

tensorboard 2.2.0 and torch 1.14.0 is worked for me.

like image 31
李金苗 Avatar answered Jan 22 '23 14:01

李金苗