Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm running a CPU intensive command on Mavericks (Opencv_traincasscade). Under Mountain Lion the process used to use all 8 cores all the way though. However after upgrading it drops to 1 core after a short time.

enter image description here

Could this be app nap? Is there anything I can do to fix this?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Being able to use multiple-cores or threads is dependent on the process. This is not AppNap or OS X causing the change.

Your process, opencv_traincascade, may be resource constrained after a few moments and thus reduced to queuing up tasks as it waits for disk access or another limited resource.

In this case you may need to switch to a different build of OpenCV:

Note that opencv_traincascade application can use TBB for multi-threading. To use it in multicore mode OpenCV must be built with TBB.

Installing OpenCV with TBB via brew:

brew install opencv --with-tbb
share|improve this answer
    
Thanks you for the answer, I will definitely give that a go. However, there are 2 reasons why I think it might not be the case. Firstly, the CPU did hit 800% for a few mins when it started, which suggested that OpenCV is capable of using all cores. Secondly I never encountered this problem on Mountain lion (however, I cant be 100% sure if it was the same build). The -mode parameter is related to rotation of feature detection not cores I believe. –  Robert May 26 at 14:33
    
Actually I take that back! You were right :D I'm going to answer for completeness. –  Robert May 26 at 16:49

Graham Miln was correct - the OpenCV installation was wrong.

To verify this:

otool -L /usr/local/lib/libopencv_core.2.4.9.dylib
# Look for libtbb.dylib in the response,
# if missing you need to reinstall with tbb.

To fix this (assuming you installed with homebrew):

brew uninstall opencv
brew info opencv # This will tell you about other flags you might be interested in.
brew install opencv --with-tbb  # Simples! :)
share|improve this answer
    
Rather than being a separate answer, consider appending this to your question. –  Graham Miln May 26 at 17:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.