How to remove diagnostic message while using torch.onnx.export

Hi,

I am wondering if there is a way to remove the console message below while using torch.onnx.export() function.

================ Diagnostic Run torch.onnx.export version 2.0.1 ================
verbose: False, log level: Level.ERROR
======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR =============

We are automating a process to create hundreds of onnx models in a row and these messages can make the log cluttered and hard to read. I understand that an older version of PyTorch (torch 1.13.1) did not have this behavior, so I’m wondering if there is a way to remove it in version 2.0.1

Thank you.

I don’t know which exact commit changed the printing behavior, but @BowenBao might know.

Hi do we have an update about it ?

Thank you

We decided to leave the diagnostic messages as is given the side effects of the two solutions below:

  1. We could run the script like this: python3 onnx_export.py >> /dev/null 2>&1 . All stdout output will be dumped into /dev/null which discards it, leaving only stderr showing. This has the side effect of getting rid of all print statements in the script, which we don’t want.
  2. We could also use an earlier version of PyTorch such as 1.13.1, but the side effect being the potential negative effects of not using the latest version of PyTorch.
1 Like

The accepted answer does not solve the problem. Users would like to avoid this output clutter.

If there are no errors to report, then by default there should be no console message. Users who wish the “Diagnostic” summary even when there are no errors should enable it explicitly.