The nonzero() operation is synchronizing the code, so unless you’ve added the manual synchronizations into your code as suggested, your timings will be wrong and the nonzero() operation will accumulate the execution time of the asynchronously launched CUDA kernels.