Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes module 'get_filesystem' error #2397

Merged
merged 3 commits into from
Jun 1, 2023
Merged

Conversation

QasimKhan5x
Copy link
Contributor

@QasimKhan5x QasimKhan5x commented Jun 1, 2023

Fixes #1919

Description

The following error occurs when running the notebook in Google Colab (which has TensorFlow installed):

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-9-cff6eb059fb9>](https://localhost:8080/#) in <module>()
     16 writer.add_embedding(features,
     17                     metadata=class_labels,
---> 18                     label_img=images.unsqueeze(1))
     19 writer.flush()
     20 writer.close()

[/usr/local/lib/python3.7/dist-packages/torch/utils/tensorboard/writer.py](https://localhost:8080/#) in add_embedding(self, mat, metadata, label_img, global_step, tag, metadata_header)
    808         save_path = os.path.join(self._get_file_writer().get_logdir(), subdir)
    809 
--> 810         fs = tf.io.gfile.get_filesystem(save_path)
    811         if fs.exists(save_path):
    812             if fs.isdir(save_path):

AttributeError: module 'tensorflow._api.v2.io.gfile' has no attribute 'get_filesystem'

The proposed (temporary) fix is to add the following code:

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

I added the code and a helpful comment, but kept the code commented to ensure it only needs to be executed by users running in Colab or other TensorFlow-enabled environments. This approach avoids introducing unnecessary dependencies.

cc @aaronenyeshi @chaekit

@QasimKhan5x QasimKhan5x changed the title Add temporary fix for embeddings bug Fixes module 'get_filesystem' error Jun 1, 2023
@netlify
Copy link

netlify bot commented Jun 1, 2023

Deploy Preview for pytorch-tutorials-preview ready!

Name Link
🔨 Latest commit e86425c
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-tutorials-preview/deploys/6478e64a19822200080c7dd5
😎 Deploy Preview https://deploy-preview-2397--pytorch-tutorials-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added tensorboard docathon-h1-2023 A label for the docathon in H1 2023 easy and removed cla signed labels Jun 1, 2023
Copy link
Contributor

@svekars svekars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, but LGMT

@svekars svekars merged commit aa400c3 into pytorch:main Jun 1, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docathon-h1-2023 A label for the docathon in H1 2023 easy tensorboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

module 'get_filesystem' error
3 participants