pytorch tensorboard "add_embedding error"

Viewed 446

everyone. I'm stuck in using tensorboard in pytorch. The point is add_embedding method makes the error like below:

Traceback (most recent call last):
  File "test2.py", line 126, in <module>
    writer.add_embedding(features, metadata=class_labels, label_img = images.unsqueeze(1))
  File "/home/dgjung/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/utils/tensorboard/writer.py", line 798, in add_embedding
    fs = tf.io.gfile.get_filesystem(save_path)
AttributeError: module 'tensorflow._api.v2.io.gfile' has no attribute 'get_filesystem'

My code is pytorch tutorial.

# log embeddings
features = images.view(-1, 28 * 28)
writer.add_embedding(features,
                    metadata=class_labels,
                    label_img=images.unsqueeze(1))

My enviroment is :

  • PyTorch : '1.7.1'
  • Tensorflow : '2.4.1'
  • Python : 3.8.8

PLZ, help me!

1 Answers

This is a nasty little bug that someone needs to patch.. There's a conversation about it here

I was able to fix it by adding:

import tensorboard as tb
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile

to torch/utils/tensorboard/writer.py just above line 798

glhf

Related