Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not get pytorch working with tensorboard

I"m going through this tutorial to set up pytorch (v1.3.0 through conda) with tensorboard https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html#

but on the step

from torch.utils.tensorboard import SummaryWriter

# default `log_dir` is "runs" - we'll be more specific here
writer = SummaryWriter('runs/fashion_mnist_experiment_1')

I keep getting the error

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
C:\ProgramData\Anaconda3\envs\fastai_v1\lib\site-packages\torch\utils\tensorboard\__init__.py in 
      1 try:
----> 2     from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
      3 except ImportError:

ModuleNotFoundError: No module named 'tensorboard.summary'; 'tensorboard' is not a package

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
c:\Users\matt\Documents\code\playground\tensorboard.py in 
----> 1 from torch.utils.tensorboard import SummaryWriter
      2 
      3 # default `log_dir` is "runs" - we'll be more specific here
      4 writer = SummaryWriter('runs/fashion_mnist_experiment_1')

C:\ProgramData\Anaconda3\envs\fastai_v1\lib\site-packages\torch\utils\tensorboard\__init__.py in 
      2     from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
      3 except ImportError:
----> 4     raise ImportError('TensorBoard logging requires TensorBoard with Python summary writer installed. '
      5                       'This should be available in 1.14 or above.')
      6 from .writer import FileWriter, SummaryWriter  # noqa F401

ImportError: TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above.

Does anyone have any suggestions?

like image 550
foobar8675 Avatar asked Nov 04 '19 02:11

foobar8675


People also ask

Does TensorBoard work with PyTorch?

tensorboard. Once you've installed TensorBoard, these utilities let you log PyTorch models and metrics into a directory for visualization within the TensorBoard UI. Scalars, images, histograms, graphs, and embedding visualizations are all supported for PyTorch models and tensors as well as Caffe2 nets and blobs.

How do you run Tensorboardx?

To run tensorboard web server, you need to install it using pip install tensorboard . After that, type tensorboard --logdir=<your_log_dir> to start the server, where your_log_dir is the parameter of the object constructor. I think this command is tedious, so I add a line alias tb='tensorboard --logdir ' in ~/. bashrc .

How do I install TensorBoard on Ubuntu?

Essentials of installing TensorBoard on ubuntu requires python to be installed on the system. And along with Python we need to have pip installed with which we can install TensorBoard. Ubuntu16. 04+ comes shipped with Python3+.


1 Answers

The error log says, among other things,

ImportError: TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above.

So, when it tries to import TensorBoard, it's unable to do so because it's missing it in the search path. You can install the latest version (without specifying any version number), as in:

$ conda install -c conda-forge tensorboard

Apart from that, you might also need to install protobuf:

$ conda install -c conda-forge protobuf

These installations should fix the ImportErrors.

like image 56
kmario23 Avatar answered Sep 19 '22 06:09

kmario23