Thread hangs there when unload the module

Hi Experts, as the topic said, the thread hangs there and block the programe, and the testing is on Windows.

    do 
    {
        std::thread th = std::thread([argc, argv]() {
            test_tvm_cam_facedetector(argc, argv);
            printf("test_tvm_cam_facedetector done \n");
        });
        th.join();
    } while (false);

    printf("th.join() done \n");

when i use the command parameter to make TVM run in GPU mode, everything is fine; but when make TVM run in CPU mode, the programe stuck at: th.join(), and the console print out: test_tvm_cam_facedetector done

This means all my application logic and thread is done. So i use the Process Explorer to check the stack, and there are really not anything about application logic and thread information, and i found something:

It seems it stuck on backend paral jobs. I don’t understand and how to solve this issue.

Looking forward to your reply, Thanks.

1 Like

Hi, @zhigaowu I faced the same problem on Windows. Which thread pool of runtime do you use? In my case, I changed the thread pool to OpenMP from default one and it works well with std::thread.

But I don’t know why default thread pool hangs…

I haven’t done much testing on CPU inferencing yet (mostly CUDA), but have had deadlocks on Windows using the default thread pool.

Like you, setting USE_OPENMP to “gnu” fixed the issues I had…though I can only speak for the state of the code a few months back and unsure if anything has been improved.

image

Really appreciate all you guys share the solution.

I use MKL as the blas library, and the default thread pool seems to be OPENMP=iomp5 and i do not configure USE_OPENMP individually.

I will reconfigure it to make USE_OPENMP to ngu, hope it will work.

Thank all you guys.

Configure USE_OPENMP=ngu or intel both work.

1 Like

Hey Experts, USE_OPENMP will lead to memory leak as described in Memory leak running in cpu mode on windows[tvm 0.6.0]

please note that.