Can use -- from tensorboardX import SummaryWriter

davidzhr: <p>error message:</p>
<blockquote>
<hr>
</blockquote>
<p>TypeError                                 Traceback (most recent call last)<br>
Cell In[10], line 1<br>
----&gt; 1 from tensorboardX import SummaryWriter</p>
<p>File /data/anaconda3/yes/envs/jupyter/lib/python3.10/site-packages/tensorboardX/<strong>init</strong>.py:4<br>
1 “”“A module for visualization with tensorboard<br>
2 “””<br>
----&gt; 4 from .writer import FileWriter, SummaryWriter<br>
5 from .record_writer import RecordWriter</p>
<p>File /data/anaconda3/yes/envs/jupyter/lib/python3.10/site-packages/tensorboardX/writer.py:24<br>
22 import json<br>
23 import os<br>
—&gt; 24 from .src import event_pb2<br>
25 from .src import summary_pb2<br>
26 from .src import graph_pb2</p>
<p>File /data/anaconda3/yes/envs/jupyter/lib/python3.10/site-packages/tensorboardX/src/event_pb2.py:16<br>
11 # @<span class="mention">@protoc_insertion_point</span>(imports)<br>
13 _sym_db = _symbol_database.Default()<br>
—&gt; 16 from tensorboard.src import summary_pb2 as tensorboard_dot_src_dot_summary__pb2<br>
19 DESCRIPTOR = _descriptor.FileDescriptor(<br>
20   name=‘tensorboard/src/event.proto’,<br>
21   package=‘tensorboard’,<br>
(…)<br>
24   ,<br>
25   dependencies=[tensorboard_dot_src_dot_summary__pb2.DESCRIPTOR,])<br>
29 _LOGMESSAGE_LEVEL = _descriptor.EnumDescriptor(<br>
30   name=‘Level’,<br>
31   full_name=‘tensorboard.LogMessage.Level’,<br>
(…)<br>
63   serialized_end=548,<br>
64 )</p>
<p>File /data/anaconda3/yes/envs/jupyter/lib/python3.10/site-packages/tensorboard/src/summary_pb2.py:16<br>
11 # @<span class="mention">@protoc_insertion_point</span>(imports)<br>
13 _sym_db = _symbol_database.Default()<br>
—&gt; 16 from tensorboard.src import tensor_pb2 as tensorboard_dot_src_dot_tensor__pb2<br>
19 DESCRIPTOR = _descriptor.FileDescriptor(<br>
20   name=‘tensorboard/src/summary.proto’,<br>
21   package=‘tensorboard’,<br>
(…)<br>
24   ,<br>
25   dependencies=[tensorboard_dot_src_dot_tensor__pb2.DESCRIPTOR,])<br>
30 _SUMMARYDESCRIPTION = _descriptor.Descriptor(<br>
31   name=‘SummaryDescription’,<br>
32   full_name=‘tensorboard.SummaryDescription’,<br>
(…)<br>
57   serialized_end=115,<br>
58 )</p>
<p>File /data/anaconda3/yes/envs/jupyter/lib/python3.10/site-packages/tensorboard/src/tensor_pb2.py:16<br>
11 # @<span class="mention">@protoc_insertion_point</span>(imports)<br>
13 _sym_db = _symbol_database.Default()<br>
—&gt; 16 from tensorboard.src import resource_handle_pb2 as tensorboard_dot_src_dot_resource__handle__pb2<br>
17 from tensorboard.src import tensor_shape_pb2 as tensorboard_dot_src_dot_tensor__shape__pb2<br>
18 from tensorboard.src import types_pb2 as tensorboard_dot_src_dot_types__pb2</p>
<p>File /data/anaconda3/yes/envs/jupyter/lib/python3.10/site-packages/tensorboard/src/resource_handle_pb2.py:35<br>
13 _sym_db = _symbol_database.Default()<br>
18 DESCRIPTOR = _descriptor.FileDescriptor(<br>
19   name=‘tensorboard/src/resource_handle.proto’,<br>
20   package=‘tensorboard’,<br>
21   syntax=‘proto3’,<br>
22   serialized_pb=_b(‘\n%tensorboard/src/resource_handle.proto\x12\x0btensorboard"r\n\x13ResourceHandleProto\x12\x0e\n\x06\x64\x65vice\x18\x01 \x01(\t\x12\x11\n\tcontainer\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x11\n\thash_code\x18\x04 \x01(\x04\x12\x17\n\x0fmaybe_type_name\x18\x05 \x01(\tB/\n\x18org.tensorflow.frameworkB\x0eResourceHandleP\x01\xf8\x01\x01\x62\x06proto3’)<br>
23 )<br>
28 _RESOURCEHANDLEPROTO = _descriptor.Descriptor(<br>
29   name=‘ResourceHandleProto’,<br>
30   full_name=‘tensorboard.ResourceHandleProto’,<br>
31   filename=None,<br>
32   file=DESCRIPTOR,<br>
33   containing_type=None,<br>
34   fields=[<br>
—&gt; 35     _descriptor.FieldDescriptor(<br>
36       name=‘device’, full_name=‘tensorboard.ResourceHandleProto.device’, index=0,<br>
37       number=1, type=9, cpp_type=9, label=1,<br>
38       has_default_value=False, default_value=_b(“”).decode(‘utf-8’),<br>
39       message_type=None, enum_type=None, containing_type=None,<br>
40       is_extension=False, extension_scope=None,<br>
41       options=None),<br>
42     _descriptor.FieldDescriptor(<br>
43       name=‘container’, full_name=‘tensorboard.ResourceHandleProto.container’, index=1,<br>
44       number=2, type=9, cpp_type=9, label=1,<br>
45       has_default_value=False, default_value=_b(“”).decode(‘utf-8’),<br>
46       message_type=None, enum_type=None, containing_type=None,<br>
47       is_extension=False, extension_scope=None,<br>
48       options=None),<br>
49     _descriptor.FieldDescriptor(<br>
50       name=‘name’, full_name=‘tensorboard.ResourceHandleProto.name’, index=2,<br>
51       number=3, type=9, cpp_type=9, label=1,<br>
52       has_default_value=False, default_value=_b(“”).decode(‘utf-8’),<br>
53       message_type=None, enum_type=None, containing_type=None,<br>
54       is_extension=False, extension_scope=None,<br>
55       options=None),<br>
56     _descriptor.FieldDescriptor(<br>
57       name=‘hash_code’, full_name=‘tensorboard.ResourceHandleProto.hash_code’, index=3,<br>
58       number=4, type=4, cpp_type=4, label=1,<br>
59       has_default_value=False, default_value=0,<br>
60       message_type=None, enum_type=None, containing_type=None,<br>
61       is_extension=False, extension_scope=None,<br>
62       options=None),<br>
63     _descriptor.FieldDescriptor(<br>
64       name=‘maybe_type_name’, full_name=‘tensorboard.ResourceHandleProto.maybe_type_name’, index=4,<br>
65       number=5, type=9, cpp_type=9, label=1,<br>
66       has_default_value=False, default_value=_b(“”).decode(‘utf-8’),<br>
67       message_type=None, enum_type=None, containing_type=None,<br>
68       is_extension=False, extension_scope=None,<br>
69       options=None),<br>
70   ],<br>
71   extensions=[<br>
72   ],<br>
73   nested_types=<span class="chcklst-box fa fa-square-o fa-fw"></span>,<br>
74   enum_types=[<br>
75   ],<br>
76   options=None,<br>
77   is_extendable=False,<br>
78   syntax=‘proto3’,<br>
79   extension_ranges=<span class="chcklst-box fa fa-square-o fa-fw"></span>,<br>
80   oneofs=[<br>
81   ],<br>
82   serialized_start=54,<br>
83   serialized_end=168,<br>
84 )<br>
86 DESCRIPTOR.message_types_by_name[‘ResourceHandleProto’] = _RESOURCEHANDLEPROTO<br>
87 _sym_db.RegisterFileDescriptor(DESCRIPTOR)</p>
<p>File /data/anaconda3/yes/envs/jupyter/lib/python3.10/site-packages/google/protobuf/descriptor.py:553, in FieldDescriptor.<strong>new</strong>(cls, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options, serialized_options, has_default_value, containing_oneof, json_name, file, create_key)<br>
547 def <strong>new</strong>(cls, name, full_name, index, number, type, cpp_type, label,<br>
548             default_value, message_type, enum_type, containing_type,<br>
549             is_extension, extension_scope, options=None,<br>
550             serialized_options=None,<br>
551             has_default_value=True, containing_oneof=None, json_name=None,<br>
552             file=None, create_key=None):  # pylint: disable=redefined-builtin<br>
 → 553   _message.Message._CheckCalledFromGeneratedFile()<br>
554   if is_extension:<br>
555     return _message.default_pool.FindExtensionByName(full_name)</p>
<p>TypeError: Descriptors cannot be created directly.<br>
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc &gt;= 3.19.0.<br>
If you cannot immediately regenerate your protos, some other possible workarounds are:</p>
<ol>
<li>Downgrade the protobuf package to 3.20.x or lower.</li>
<li>Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).</li>
</ol>
<p>More information: <a href="https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates" class="inline-onebox" rel="noopener nofollow ugc">Changes announced May 6, 2022 | Protocol Buffers Documentation</a></p>
<p>More information: <a href="https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates" class="inline-onebox" rel="noopener nofollow ugc">Changes announced May 6, 2022 | Protocol Buffers Documentation</a></p>
<p>my env:</p>
<blockquote>
<p>Blockquote<br>
pip list | grep torch<br>
tensorboard-pytorch               0.7.1<br>
torch                             2.2.2+cu118<br>
torchaudio                        2.2.2+cu118<br>
torchvision                       0.17.2+cu118</p>
</blockquote>

ptrblck: <p>Check your <code>protobuf</code> version as this error was seen in a lot of setups due to breaking changes in their update. Then make sure you are using a supported <code>protobuf</code> version required by your <code>tensorboard</code>.</p>