Problem description
An error occurs when executing the following command:
from torch.utils.tensorboard import SummaryWriter
tb_writer = SummaryWriter(osp.join(opt.savepath, "logdir"))
Error content:
AttributeError: module 'tensorflow._api.v1.io' has no attribute 'gfile'
Problem analysis
The root cause of this problem is that pytorch has adjusted tensorflow. Finally, tensorflow reports an error. The new version of tensorflow is incompatible with the old version.
After checking, my pytorch version is 1.6, tensorboard version is 1.15.0, and tensorflow version is 1.12.0
Problem-solving:
Upgrade the tensorflow version to version 2.0. Executing the following command will automatically upgrade the tensorflow version and tensorboard version:
pip install tensorflow==2.0
End.
Read More:
- [Solved] AttributeError: module ‘tensorflow‘ has no attribute ‘distributions‘
- Python AttributeError: module ‘tensorflow‘ has no attribute ‘InteractiveSession‘
- [Solved] AttributeError: module ‘tensorboard.summary._tf.summary‘ has no attribute ‘merge‘
- [Solved] Error: AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘
- [Solved] AttributeError: module ‘tensorflow._api.v2.train‘ has no attribute ‘AdampOptimizer‘
- [Solved] AttributeError: module ‘setuptools._distutils‘ has no attribute ‘version‘
- [Solved] AttributeError: module ‘distutils‘ has no attribute ‘version‘
- [Solved] Pytorch Error: AttributeError: ‘Tensor‘ object has no attribute ‘backword‘
- [Solved] Pytorch-transformers Error: AttributeError: ‘str‘ object has no attribute ‘shape‘
- [How to Solve]AttributeError: module ‘scipy’ has no attribute ‘io’
- AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘ [How to Solve]
- AttributeError: module ‘time‘ has no attribute ‘clock‘ [How to Solve]
- [Solved]AttributeError: module ‘urllib’ has no attribute ‘quote’
- [Solved] AttributeError: module ‘pandas‘ has no attribute ‘rolling_count‘
- [Solved] AttributeError: module ‘selenium.webdriver‘ has no attribute ‘Chrome‘
- [Solved] AttributeError: partially initialized module ‘xlwings’ has no attribute ‘App’
- Python3.7 AttributeError: module ‘time‘ has no attribute ‘clock‘
- [Solved] AttributeError: module ‘time‘ has no attribute ‘clock‘
- [Solved] AttributeError: module ‘dlib‘ has no attribute ‘get_face_chip‘
- [Solved] AttributeError: module ‘logging‘ has no attribute ‘Handler‘