3

I follow the tutorials in pytorch.org It occurs error:TensorBoard logging requires TensorBoard version 1.15 or above,but I have install TensorBoard already. Here is the code:

#from torch.utils.tensorboard import SummaryWriter
from tensorboardX import SummaryWriter
writer = SummaryWriter('runs/fashion_mnist_experiment_1')
#get some random training images
dataiter = iter(trainloader)
images , labels = dataiter.next()
#create grid of images
img_grid = torchvision.utils.make_grid(images)
matplotlib_imshow(img_grid,one_channel=True)
writer.add_image('four_fashion_images',img_grid)
writer.add_graph(net, images)
writer.close()

Error:

ImportError                               Traceback (most recent call last)
<ipython-input-12-d38808675cb4> in <module>
----> 1 writer.add_graph(net, images)
      2 writer.close()

~\anaconda3\envs\torch2\lib\site-packages\tensorboardX\writer.py in add_graph(self, model, input_to_model, verbose)
    791 
    792         """
--> 793         from torch.utils.tensorboard._pytorch_graph import graph
    794         self._get_file_writer().add_graph(graph(model, input_to_model, verbose))
    795 

~\anaconda3\envs\torch2\lib\site-packages\torch\utils\tensorboard\__init__.py in <module>
      2 from distutils.version import LooseVersion
      3 if not hasattr(tensorboard, '__version__') or LooseVersion(tensorboard.__version__) < LooseVersion('1.15'):
----> 4     raise ImportError('TensorBoard logging requires TensorBoard version 1.15 or above')
      5 del LooseVersion
      6 del tensorboard

ImportError: TensorBoard logging requires TensorBoard version 1.15 or above

Environment:

tensorboard               2.3.0                    pypi_0    pypi
tensorboard-plugin-wit    1.7.0                    pypi_0    pypi
tensorboardx              2.1                      pypi_0    pypi
tensorflow                1.2.1                    py36_0    defaults
pytorch                   1.6.0           py3.6_cuda102_cudnn7_0    pytorch
torchvision               0.7.0                py36_cu102    pytorch
future                    0.18.2                   py36_1    defaults
protobuf                  3.12.3           py36h33f27b4_0    defaults

I use from torch.utils.tensorboard import SummaryWriter at the beginning,but it occurs the error as same as above.Then I use from tensorboardX import SummaryWriter

zhan
  • 85
  • 1
  • 1
  • 9

5 Answers5

4

Uninstall tensorflow, tensorboard, tensorboardx and tensorboard-plugin-wit.

Install only tensorboard with conda after that.

If this doesn't work, recreate your conda environment only with tensorboard. If you need tensorflow as well install it beforehand.

EDIT:

tensorboard-plugin-wit is a dependency of tensorboard and should be installed automatically as per their pypi description when installing tensorboard itself.

Szymon Maszke
  • 22,747
  • 4
  • 43
  • 83
  • I recreate my conda environment with pytorch1.6 and tensorboard.When I install tensorboard,the tensorboard-plugin-wit will be installed automatically.For the [from torch.utils.tensorboard import SummaryWriter],it occurs the error ImportError: TensorBoard logging requires TensorBoard version 1.15 or above – zhan Aug 11 '20 at 15:42
  • The bug confuses me for days. – zhan Aug 11 '20 at 15:44
  • @zhan could you install `pip` within conda and install [this package](https://pypi.org/project/tensorboard) afterwards? I assume you are installing `<1.15.0`, this might help. Remember to pin version via `pip install tensorboard==2.3.0`. – Szymon Maszke Aug 11 '20 at 17:37
  • I do as you say. It occurs the error. I use `conda list` to see the version of `tensorboard` which is 2.3.0. – zhan Aug 12 '20 at 02:07
  • I use `from tensorboard import version print(version.VERSION)` , it print `1.14.0a20190301` .But the version of the tensorboard i install is 2.3.0. – zhan Aug 12 '20 at 03:02
  • 1
    The `1.14.0a20190301` is the version of `tb-nightly`.I uninstall `tb-nightly`, It works. But I don't remember l have installed `tb-nightly` before. – zhan Aug 12 '20 at 06:05
  • I don't understand, what is causing this issue? – Charlie Parker Mar 29 '21 at 19:16
  • btw `tensorboard-plugin-wit` installs itself...I can't not have it not install itself. – Charlie Parker Mar 29 '21 at 19:20
  • @CharlieParker IIRC this happens if you install old `tensorboardX` that PyTorch is not using anymore (as it directly relies on `tensorboard`). Do you have `tensorboardX`? – Szymon Maszke Mar 29 '21 at 19:23
  • @SzymonMaszke I do not have `tensorboardX`. I have `tensorboard 2.4.0 pyhc547734_0 tensorboard-plugin-wit 1.6.0 py_0 tensorflow-estimator 2.4.0 pypi_0 pypi ` from doing your suggestion. It's really strange. – Charlie Parker Mar 29 '21 at 19:48
  • Yeah, `tensorboard-plugin-wit` is apparently dependency of `tensorboard` (check out their [pypi package](https://pypi.org/project/tensorboard-plugin-wit/)), so should be fine. Is it not? – Szymon Maszke Mar 29 '21 at 19:52
  • though it does import if I go to the terminal ```$ python Python 3.8.2 (default, Mar 26 2020, 15:53:00) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> import KeyboardInterrupt >>> from torch.utils.tensorboard import SummaryWriter >>> ```...it's somehow if I do it from my project it doesn't work https://github.com/brando90/ultimate-utils/blob/master/ultimate-utils-project/uutils/torch/distributed.py it's a single completely self contained example that doesn't seem to work. – Charlie Parker Mar 29 '21 at 19:52
  • Make sure you are the same environments in both cases, if you do, it is likely not related to `tensorboard` dependency (probably new stackoverflow question should be posted). – Szymon Maszke Mar 29 '21 at 19:56
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/230515/discussion-between-charlie-parker-and-szymon-maszke). – Charlie Parker Mar 29 '21 at 19:57
2

My problem was that my directory I was working in was named tensorboard, so it tried to import from the current directory instead of from the installed package. So I suggest trying to rename the directory to see if it helps.

Maxis
  • 384
  • 2
  • 13
2

Do

conda uninstall tensorflow
conda uninstall tensorboard
conda uninstall tensorboardx
conda uninstall tensorboard-plugin-wit
conda uninstall cloud-tpu-client
pip uninstall tensorflow
pip uninstall tensorboard
pip uninstall tensorboardx
pip uninstall tensorboard-plugin-wit
pip uninstall cloud-tpu-client

then

conda install tensorboard
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
0

I both tried conda install and pip install, but this error still occurred when I used from torch.utils.tensorboard import SummaryWriter in an ipynb file. And I checked not hasattr(tensorboard, '__version__') or LooseVersion(tensorboard.__version__) < LooseVersion('1.15'), which both are False, meaning that it won't raise an error.

At last, I closed this ipynb file and restarted it, it worked. You should try this and no need to be struggling in reinstalling your conda env.

0

For my case, I had only Tensorboard without Tensorflow when I faced the error, so I had to:

  conda uninstall tensorboard - this removed PyTorch Lightning as well
  conda install tensorboard
  conda install -c conda-forge pytorch-lightning

Cloud Cho
  • 1,594
  • 19
  • 22