torch::NoGradGuard appears thread suspending

Hi, When I use libtorch to forward audios with GPU and use torch::NoGradGuard, The first audio file is normal, but the second will appear thread suspending, the GPU utilization become 0. After a moment, this will be fine and never appear suspending. When I use multi thread, they are all suspending when forward the second audio file in every thread, I must wait quite a long time…

When I use libtorch to forward audios with GPU and not use torch::NoGradGuard, Thread suspending will much better, however, still a few thread suspending I can feel.

I change torch::NoGradGuard into torch::autogrid::AutoGradMode guard(false), get same situation.

I have no idea about that, can anybody help?

Hi,

This is hard to say. Are you sure that you don’t have other work that is happening there that happens on the side?

If not, you can use gdb and suspend the execution while it seems to “hang” and see where it is.