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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ONNX --dynamic export on GPU #8378

Merged
merged 2 commits into from
Jun 28, 2022
Merged

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Jun 28, 2022

Patch forces --dynamic export model and image to CPU. Resolves bug raised in #8377

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhanced ONNX export compatibility and adjusted half precision handling during export.

πŸ“Š Key Changes

  • Modified the export_onnx function in export.py to move models and input tensors to CPU when using the --dynamic flag.
  • Changed the order of operations in the run function to apply half precision (FP16) to the model and input only after initial model dry runs.

🎯 Purpose & Impact

  • The update to the ONNX export function ensures that dynamic exports work as intended, as dynamic operations are only compatible with CPU. This allows for smoother conversion of models to ONNX format when using dynamic axes. πŸ”„
  • Adjusting when half precision is applied prevents potential issues during model export, such as incompatibilities with certain export targets like CoreML and XML which do not support FP16. This ensures more stable and reliable model export, particularly beneficial for users working with mixed precision to optimize performance. πŸƒβ€β™‚οΈπŸ’¨

Patch forces --dynamic export model and image to CPU. Resolves bug raised in #8377
@glenn-jocher glenn-jocher self-assigned this Jun 28, 2022
@glenn-jocher glenn-jocher merged commit 0c13240 into master Jun 28, 2022
@glenn-jocher glenn-jocher deleted the fix/onnx_dynamic_device0 branch June 28, 2022 13:22
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* Fix ONNX `--dynamic` export on GPU

Patch forces --dynamic export model and image to CPU. Resolves bug raised in ultralytics#8377

* Update export.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant