Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to Supress ONNX warnnings #77494

Closed
ganler opened this issue May 15, 2022 · 1 comment
Closed

Option to Supress ONNX warnnings #77494

ganler opened this issue May 15, 2022 · 1 comment
Assignees
Labels
module: onnx Related to torch.onnx onnx-triaged triaged by ONNX team triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@ganler
Copy link
Contributor

ganler commented May 15, 2022

馃悰 Describe the bug

When exporting ONNX, there can be a bunch of warnings that warning.simplefilter can not filter. After some digging, I found such messages are directly from the C++ code base via std::cerr.

I don't think such behaviors are good as libraries should not print arbitrary stuffs w/o an option to close it. So can we simply use TORCH_WARN:

TORCH_WARN("CUDA initialization: ", ex.msg());

or something similar?

Related issue: ultralytics/yolov5#6401

cc: @BowenBao @garymm

Versions

PyTorch version: 1.11.0+cu102

@glenn-jocher
Copy link

Agree, this bug is printing many unnecessary warnings on YOLOv5 ONNX export.

@garymm garymm added module: onnx Related to torch.onnx onnx-triaged triaged by ONNX team labels May 16, 2022
@mikaylagawarecki mikaylagawarecki added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label May 23, 2022
@justinchuby justinchuby linked a pull request Jun 1, 2022 that will close this issue
@justinchuby justinchuby self-assigned this Jun 6, 2022
facebook-github-bot pushed a commit that referenced this issue Jun 7, 2022
Summary:
Warnings were output to `std::cerr` in onnx jit passes. This prevents them from being filtered out. This PR replaces them with `TORCH_WARN` so we get more pythonic warnings.

- Use `TORCH_WARN` to for warnings
- Wrap jit passes with `wrap_pybind_function` when binding with python to handle the warnings properly

Calm test outputs, nice:

![image](https://user-images.githubusercontent.com/11205048/171510581-67299e9a-2dcd-4950-9cf3-ed67431f1f0c.png)

![image](https://user-images.githubusercontent.com/11205048/171516351-98bd342b-5f0a-4877-98c2-3be863b7f795.png)

Fixes #77494

Pull Request resolved: #78441
Approved by: https://github.com/garymm

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/491c2ed2812cec3861158754bf053ecc12f8e6d6

Reviewed By: osalpekar

Differential Revision: D36959145

Pulled By: osalpekar

fbshipit-source-id: eaecba6fae9e5cb4c26045c257201ebd2fd4580b
justinchuby added a commit to justinchuby/pytorch that referenced this issue Jul 27, 2022
Warnings were output to `std::cerr` in onnx jit passes. This prevents them from being filtered out. This PR replaces them with `TORCH_WARN` so we get more pythonic warnings.

- Use `TORCH_WARN` to for warnings
- Wrap jit passes with `wrap_pybind_function` when binding with python to handle the warnings properly

Calm test outputs, nice:

![image](https://user-images.githubusercontent.com/11205048/171510581-67299e9a-2dcd-4950-9cf3-ed67431f1f0c.png)

![image](https://user-images.githubusercontent.com/11205048/171516351-98bd342b-5f0a-4877-98c2-3be863b7f795.png)

Fixes pytorch#77494
Pull Request resolved: pytorch#78441
Approved by: https://github.com/garymm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: onnx Related to torch.onnx onnx-triaged triaged by ONNX team triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants