Expose setNumThreads in Python module (Feature #4456)


Added by Damon Maria over 9 years ago. Updated over 9 years ago.


Status:Done Start date:2015-06-30
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:python bindings
Target version:-
Difficulty: Pull request:https://github.com/Itseez/opencv/pull/4168

Description

Python applications often fork multiple processes to get around the Python Global Interpreter Lock. I use 60 forked processes in my application on a 64 core machine. But that means TBB is creating 64 threads in each of those 60 processes. I know the answer is to use setNumThreads(0) in the forked processes but I use the Python (3) API and that function is not exposed in the cv2 module.

In the meantime is there any workaround? Can I link to an OpenCV .so directly using ctypes and call the function?


Related issues

related to Bug #4064: Export thread controlling functions to the automatic gene... Done 2014-12-14
related to Bug #4353: 100% CPU / lockup / stalled in cv::ThresholdRunner::opera... Cancelled 2015-05-21

History

Updated by Damon Maria over 9 years ago

Issue #4064 seems to be exactly for this but it appears from the PR on Github that it was only merged into OpenCV 2.4. Can the same be done for 3.0 please.

When I change CV_EXPORTS to CV_EXPORTS_W for those functions in modules/core/include/opencv2/core/utility.hpp and recompile it works.

I'll see if I can figure out how to create a PR.

Updated by Philip L over 9 years ago

I opened a corresponding PR for you: https://github.com/Itseez/opencv/pull/4168

since this is already in 2.4 i think this will get merged tomorrow or at friday if there are no other concerns by the opencv devs

  • Status changed from New to Open

Updated by Alexander Alekhin over 9 years ago

  • Status changed from Open to Done
  • Pull request set to https://github.com/Itseez/opencv/pull/4168

Updated by Damon Maria over 9 years ago

Awesome. Thanks for the quick response guys.

Also available in: Atom PDF