synchronize inputs to onnx session on GPU #1061
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Running GPU preprocessed inference while another process used the GPU sometimes caused the ONNX model to produce unexpected output. By asking the ONNX session to ensure that its input buffer is synchronized prior to running inference, we resolve this issue. We also cause faster inference. With CPU based preprocessing, my test based on our client's use case runs in 130ms. With GPU, we get 40ms. With synchronization, we get 22ms.
Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
I ran inference while training a neural network in another process. Without synchronization, the model would sometimes produce confidences that were all 0s or all 1s. With synchronization, I no longer observe that behavior.
If there's interest I could try to build a test case that covers this, but it would have to run on GPU and may randomly pass anyway.
Any specific deployment considerations
For example, documentation changes, usability, usage/costs, secrets, etc.
Docs