How can I guarantee GPU use? #19453
-
I have a test program written in C# that performs inference on an image multiple times using a YOLOv8n network and ONNXRuntime. It is a crude benchmarking program used to ballpark inference times taken on CPU vs GPU. An anomaly that I keep running into and am unable to diagnose is that usually the GPU benchmark will be considerably faster than the CPU benchmark, taking about 20ms per frame to the CPU's ~60+ ms-per-frame on my laptop, but sometimes they will show almost identical inference times. Some characteristics of the anomaly:
These two points together suggest to me that sometimes ONNXRuntime chooses to perform inference on the CPU even though I have told it to perform it on the GPU, where "told it to" means that I used My questions:
I think profiling may help but I don't know how to read the output. I'm afraid I am not able to share the entire code snippet. I will share my Program.cs file and will include snippets of the Inference.cs code. Program.cs:
Some pieces of Inference.cs:
Some of Utils.cs:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Turn on verbose mode and look for "Node placements" in the logs. It'll tell you which nodes were placed on the GPU and which were placed on the CPU. This is not something that changed each time you create a session; it's determinate. |
Beta Was this translation helpful? Give feedback.
Turn on verbose mode and look for "Node placements" in the logs. It'll tell you which nodes were placed on the GPU and which were placed on the CPU. This is not something that changed each time you create a session; it's determinate.