Skip to content

Conversation

Vivswan
Copy link

@Vivswan Vivswan commented Jan 9, 2023

Fixed Error:
Line 72 and 86: AttributeError: module 'tensorflow' has no attribute 'io'

since:
from tensorboard.compat import tf == tensorflow
which gives AttributeError: module 'tensorflow' has no attribute 'io'
but we need:
from tensorboard.compat import tensorflow_stub as tf

now 'io' can be imported from tensorflow_stub

Fixed Error:
AttributeError: module 'tensorflow' has no attribute 'io'

since: 
    from tensorboard.compat import tf == tensorflow
    which gives AttributeError: module 'tensorflow' has no attribute 'io'
but we need: 
    from tensorboard.compat import tensorflow_stub as tf

now 'io' can be imported from tensorflow_stub
@google-cla
Copy link

google-cla bot commented Jan 9, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Vivswan Vivswan marked this pull request as draft January 9, 2023 00:29
@Vivswan Vivswan marked this pull request as ready for review January 9, 2023 00:29
@nfelt
Copy link
Contributor

nfelt commented Jan 9, 2023

Hi, thanks for your interest in contributing. Can you please provide more detail about how this bug is triggered, with all the information we would need to reproduce the issue? A good way to do this might be to first open an issue and fill out our issue template (including the environment-specific information collected by the script), so we can better understand the bug you're fixing, prior to sending the PR.

@Vivswan
Copy link
Author

Vivswan commented Jan 10, 2023

Sorry, next time, I will definitely open a issue first.

Python Code:

import traceback

from torch.utils.tensorboard import SummaryWriter
from tensorboard.summary.writer.event_file_writer import EventFileWriter

if __name__ == '__main__':
    print()
    print("EventFileWriter:")
    print()
    try:
        EventFileWriter("C:/X")
    except Exception as e:
        print(traceback.format_exc())

    print()
    print("SummaryWriter:")
    print()
    try:
        SummaryWriter(log_dir="C:/X")
    except Exception as e:
        print(traceback.format_exc())

Error:


EventFileWriter:

Traceback (most recent call last):
  File "C:\Projects\AnalogVNN\research\test.py", line 11, in <module>
    EventFileWriter("C:/X")
  File "C:\ProgramData\Anaconda3\envs\Vivswan-AnalogVNN\lib\site-packages\tensorboard\summary\writer\event_file_writer.py", line 72, in __init__
    tf.io.gfile.makedirs(logdir)
  File "C:\ProgramData\Anaconda3\envs\Vivswan-AnalogVNN\lib\site-packages\tensorboard\lazy.py", line 65, in __getattr__
    return getattr(load_once(self), attr_name)
AttributeError: module 'tensorflow' has no attribute 'io'


SummaryWriter:

Traceback (most recent call last):
  File "C:\Projects\AnalogVNN\research\test.py", line 19, in <module>
    SummaryWriter(log_dir="C:/X")
  File "C:\ProgramData\Anaconda3\envs\Vivswan-AnalogVNN\lib\site-packages\torch\utils\tensorboard\writer.py", line 247, in __init__
    self._get_file_writer()
  File "C:\ProgramData\Anaconda3\envs\Vivswan-AnalogVNN\lib\site-packages\torch\utils\tensorboard\writer.py", line 278, in _get_file_writer
    self.log_dir, self.max_queue, self.flush_secs, self.filename_suffix
  File "C:\ProgramData\Anaconda3\envs\Vivswan-AnalogVNN\lib\site-packages\torch\utils\tensorboard\writer.py", line 77, in __init__
    log_dir, max_queue, flush_secs, filename_suffix
  File "C:\ProgramData\Anaconda3\envs\Vivswan-AnalogVNN\lib\site-packages\tensorboard\summary\writer\event_file_writer.py", line 72, in __init__
    tf.io.gfile.makedirs(logdir)
  File "C:\ProgramData\Anaconda3\envs\Vivswan-AnalogVNN\lib\site-packages\tensorboard\lazy.py", line 65, in __getattr__
    return getattr(load_once(self), attr_name)
AttributeError: module 'tensorflow' has no attribute 'io'

Version:

>  pip list | findstr "tensor" 

tensorboard                   2.11.0
tensorboard-data-server       0.6.1
tensorboard-plugin-wit        1.8.1
tensorflow                    2.11.0
tensorflow-estimator          2.11.0
tensorflow-intel              2.11.0
tensorflow-io                 0.29.0
tensorflow-io-gcs-filesystem  0.29.0

@Vivswan
Copy link
Author

Vivswan commented Jan 10, 2023

Sorry, with additional testing I figured out this only happens when pytorch is installed as well. I will report the bug to pytorch then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants