AttributeError: module 'torch.utils' has no attribute 'tensorboard'
I tried to use tensorboard in torch.utils, but it says &quot;module 'torch.utils' has no attribute 'tensorboard'&quot;.
My torch version is &quot;1.6.0+cu101&quot;
PS C:\Users\kelekelekle&gt; python
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 01:54:44) [MSC v.1916 64 bit (AMD64)] on win32
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import torch
&gt;&gt;&gt; print(torch.__version__)
1.6.0+cu101
&gt;&gt;&gt; writer = torch.utils.tensorboard.SummaryWriter()
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
AttributeError: module 'torch.utils' has no attribute 'tensorboard'
&gt;&gt;&gt;


You have to install tensorboard via:
pip install tensorboard

(or a-like). Given that is done, you should import tensorboard module from torch.utils package:
from torch.utils import tensorboard

tensorboard.SummaryWriter(&quot;foo&quot;)

Or you can import SummaryWriter directly:
from torch.utils.tensorboard import SummaryWriter

SummaryWriter(&quot;bar&quot;)

