You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GPU kernels get stopped after 2 seconds on Pixel 4 when in batch mode benchmarking #5052
Describe the bug
I tried to run batch mode benchmarking on MobileNetV2. With tracy, I know that it actually takes ~60ms to finish one inference on Pixel 4 on GPU. If I benchmark the model with size=32, it reports ~60 ms. However, I found something weird when setting the size larger. I found that a launch of GPU kernel always gets stopped after 2 seconds on Pixel 4. The launch will always end at 2 seconds if I set the size >= 64.
This only happens on Pixel 4 (or andoird). For desktop, it can take more than 2 seconds to finish the work.
For CPU, it can also takes more than 2 seconds to finish the work.
It can be reproduced by any models. I simplified the command to default config and verified that it can be repro with above instructions. By default it runs in ~1 sec. Making it 5 still make the program end in 2 seconds.
Interesting. Probably due to some emulated timeline semaphore weirdness. We don't have native timeline semaphore support on Pixel4 so enumerated timeline semaphore is chosen there.
changed the title [-]GPU kernels get stopped after 2 seconds on Pixel 4[/-][+]GPU kernels get stopped after 2 seconds on Pixel 4 when in batch mode benchmarking[/+]on Mar 10, 2021
Are you getting a VK_ERROR_DEVICE_LOST return if trying to call vulkan after the 2s? OS usually has a watchdog that will reset the device if it thinks the GPU is hung.
Is the issue just that the work is finishing faster than you expect? you aren't inserting barriers between the dispatches (which is fine), which means all will run concurrently, and you may just be completing it fast :)
Try running on CPU with more than 1 thread enabled and you should see the same - 2 threads should run 2x faster, etc.
I get this error if I run with --benchmark_repetitions=2
F ../iree/hal/vulkan/emulated_semaphore.cc:140] Check failed: outstanding_semaphores_.empty() Destroying an emulated timeline semaphore without first waiting on outstanding signals
Aborted
Is the issue just that the work is finishing faster than you expect? you aren't inserting barriers between the dispatches (which is fine), which means all will run concurrently, and you may just be completing it fast :)
Try running on CPU with more than 1 thread enabled and you should see the same - 2 threads should run 2x faster, etc.
No, I think the issue is not the work is finishing faster than I expect. It should converge to a number when batch_size gets larger. But it always stops after 2 seconds.
so to clarify cause there's a lot going on in here: this reproduces on desktop with native semaphores? if so, do the vulkan debug layers print out anything?
hi, I think it is the adreno driver that stops too long tasks. There may be an internal watchdog inside the driver.
For practical uses, do not encode very large command, split into several small commands as a workaround.
Thanks @nihui for the insights! Now we know 2s is the kill threshold for Pixel 4 or Qualcomm SoC. :) Yes, this is just duplicating dispatches in a command buffer for benchmarking purposes, so that we can hide overhead. It is not meant for production usage.
Activity
antiagainst commentedon Mar 10, 2021
Interesting. Probably due to some emulated timeline semaphore weirdness. We don't have native timeline semaphore support on Pixel4 so enumerated timeline semaphore is chosen there.
[-]GPU kernels get stopped after 2 seconds on Pixel 4[/-][+]GPU kernels get stopped after 2 seconds on Pixel 4 when in batch mode benchmarking[/+]ScottTodd commentedon Mar 10, 2021
You could use emulated timeline semaphores on non-Android to investigate that theory.
My first thought was some other Vulkan ICD timeout. If a particular dispatch takes too long, we may need to split it up into several dispatches.
antiagainst commentedon Mar 10, 2021
+1 to what @ScottTodd said. You can force timeline semaphore on by
--vulkan_force_timeline_semaphore_emulation.hanhanW commentedon Mar 10, 2021
I tried it on desktop. Looks like it is not the issue of emulated timeline semaphores. It takes 4 seconds to finish the work.
ThomasRaoux commentedon Mar 10, 2021
Are you getting a VK_ERROR_DEVICE_LOST return if trying to call vulkan after the 2s? OS usually has a watchdog that will reset the device if it thinks the GPU is hung.
benvanik commentedon Mar 10, 2021
Is the issue just that the work is finishing faster than you expect? you aren't inserting barriers between the dispatches (which is fine), which means all will run concurrently, and you may just be completing it fast :)
Try running on CPU with more than 1 thread enabled and you should see the same - 2 threads should run 2x faster, etc.
hanhanW commentedon Mar 10, 2021
I get this error if I run with
--benchmark_repetitions=2hanhanW commentedon Mar 10, 2021
No, I think the issue is not the work is finishing faster than I expect. It should converge to a number when batch_size gets larger. But it always stops after 2 seconds.
benvanik commentedon Mar 10, 2021
so to clarify cause there's a lot going on in here: this reproduces on desktop with native semaphores? if so, do the vulkan debug layers print out anything?
hanhanW commentedon Mar 10, 2021
No. So far I can only repro it on Pixel 4.
hanhanW commentedon Mar 11, 2021
This looks like a Pixel 4 specific issue. Maybe it only happens on my Pixel 4...
Below is the result from S10, which looks good to me.

nihui commentedon Mar 11, 2021
hi, I think it is the adreno driver that stops too long tasks. There may be an internal watchdog inside the driver.
For practical uses, do not encode very large command, split into several small commands as a workaround.
antiagainst commentedon Mar 11, 2021
Thanks @nihui for the insights! Now we know 2s is the kill threshold for Pixel 4 or Qualcomm SoC. :) Yes, this is just duplicating dispatches in a command buffer for benchmarking purposes, so that we can hide overhead. It is not meant for production usage.
hanhanW commentedon Mar 11, 2021
Thanks, I will keep this in mind when setting benchmarking configurations!
Reduce benchmarking iterations for Adreno GPU kernel execution
Reduce benchmarking iterations for Adreno GPU kernel execution (#6097)