Skip to content

Commit

Permalink
Setting log level of onnx and dynamo to ERROR
Browse files Browse the repository at this point in the history
Reducing amount of logs that is not relevant to the user
  • Loading branch information
SebieF committed Nov 18, 2024
1 parent baf47f3 commit 98ee386
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion biotrainer/solvers/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def save_as_onnx(self, embedding_dimension: int, output_dir: Optional[str] = Non
self.network.eval()

# Export
export_options = torch.onnx.ExportOptions(dynamic_shapes=True)
export_options = torch.onnx.ExportOptions(dynamic_shapes=True, op_level_debug=False)
onnx_program = torch.onnx.dynamo_export(self.network, dummy_input,
export_options=export_options)
onnx_file_name = f"{output_dir}/{self.checkpoint_name.split('.')[0]}.onnx"
Expand Down
5 changes: 5 additions & 0 deletions biotrainer/utilities/executer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import torch
import logging

from ruamel import yaml
Expand Down Expand Up @@ -29,6 +30,10 @@ def _setup_logging(output_dir: str):
logging.StreamHandler()]
)
logging.captureWarnings(True)
# Only log errors for onnx and dynamo
torch._logging.set_logs(dynamo=logging.ERROR, onnx=logging.ERROR, onnx_diagnostics=False)
for logger_name in ["torch.onnx", "torch._dynamo", "onnxscript"]:
logging.getLogger(logger_name).setLevel(logging.ERROR)


def _write_output_file(out_filename: str, config: dict) -> None:
Expand Down

0 comments on commit 98ee386

Please sign in to comment.