Use TVM-DarkNet to detect vidoes, after relay.build_module.build, cv2 ops cost much more time

In AutoTVM, the default behavior is to use multiprocessing.Pool to use all cpu cores. However, if we start a tvm threading backend before running autotvm, cpu affinity will be changed. As a result, all processes created by mp.Pool will inherit the affinity.

1 Like

PR: https://github.com/apache/incubator-tvm/pull/4344. Please help to review and comment.

I am not familiar with this use case. But even if you start the tvm threading backend before running autotvm, I am assuming that by default you will use all cores correct? Why would you be limited by one thread? How does this relate to the setting of exclude_work0_?

All threads created by Python run on core 0 (although we create threads with the same number of the cores) because they are forked from the master thread. The problem is that cpu affinity will be inherited to children.

I understand the Python behavior and cpu affinity inheritance issue. But why setting exclude_work0_ to be true or false would make a difference? This issue sound more like about if or not we should bind threads explicitly.

If exclude_work0_==False, then master thread (and its children) can run on any core right?

Oh, I get what you meant now. Thanks for the clarification. On a second thought, perhaps we should bind master thread in any case as long as we invoke SetAffinity.