Skip to content

Commit 5406f31

Browse files
authored
Fix TensorBoardCallback for older versions of PyTorch (#8239)
1 parent d1ad4bf commit 5406f31

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/transformers/integrations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ def on_train_begin(self, args, state, control, **kwargs):
282282
if hasattr(model, "config") and model.config is not None:
283283
model_config_json = model.config.to_json_string()
284284
self.tb_writer.add_text("model_config", model_config_json)
285-
self.tb_writer.add_hparams(args.to_sanitized_dict(), metric_dict={})
285+
# Version of TensorBoard coming from tensorboardX does not have this method.
286+
if hasattr(self.tb_writer, "add_hparams"):
287+
self.tb_writer.add_hparams(args.to_sanitized_dict(), metric_dict={})
286288

287289
def on_log(self, args, state, control, logs=None, **kwargs):
288290
if state.is_world_process_zero:

0 commit comments

Comments
 (0)