Ask Your Question

Revision history [back]

I also undirectly found same problem and what can be the beginning of an explanation. Indeed anytime I run the openpose program or use openpose library in a program of my own only a unique CPU is used (use system monitor like tool to see this) !!

So I was suspecting that the problem come from CPU affinity and I can confirm that openpose code does not force CPU affinity so it may come from a dependency and opencv is one of them.

I also saw that I could not combine some libraries using multiple threads with opencv. Same as in this thread if we just link with opencv, performance of the system does not reach real time requirements of those libraries internal threads while without opencv (but using exactly the same code) everything works like a charm.

This is explained by an affinity forced to a unique CPU for any process linked with opencv.

As a note the behavior is the same with opencv 3.4.0 and 3.4.1, either on ubuntu 16.04 and 18.04, and either using clang or gcc.

I have no precise idea why this is happening and wondering if it may come from opencv or from one of its dependencies...

I also undirectly found same problem and what can be the beginning of an explanation. Indeed anytime I run the openpose program or use openpose library in a program of my own only a unique CPU is used (use system monitor like tool to see this) !!

So I was suspecting that the problem come from CPU affinity and I can confirm that openpose code does not force CPU affinity so it may come from a dependency and opencv is one of them.

I also saw that I could not combine some libraries using multiple threads with opencv. Same as in this thread if we just link with opencv, performance of the system does not reach real time requirements of those libraries internal threads while without opencv (but using exactly the same code) everything works like a charm.

This is explained by an affinity forced to a unique CPU for any process linked with opencv.

As a note the behavior is the same with opencv 3.4.0 and 3.4.1, either on ubuntu 16.04 and 18.04, and either using clang or gcc.

I have no precise idea why this is happening and wondering if it may come from opencv or from one of its dependencies...

EDIT: the problem came from the openblas library used by opencv. The solution was to rebuild openblas with NO_AFFINITY=1 CMake option (this finally deactivate parts of the code that do calls to sched_setaffinity. After rebuild everything works as expected...