-
Notifications
You must be signed in to change notification settings - Fork 896
Performance issue: much slower compared to "vanilla" opencv #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think something related that could help would be documentation on how Maybe a link to the relevant build files/flags would help? |
I didn't checked the details, but it doesn't look like generic compiler optimizations are disabled. While compiling opencv-python I see options such as -O2 and -O3 passed to the compiler. The packages I compiled are also generic x86_64 and not tuned to any CPU architecture. |
You can check the compiler flags as well as other information about the build environment with About the performance issue: it might be that pthreads vs. OpenMP is the culprit. Hard to say. Keep in mind that these packages are not optimized for performance. The main target is to provide an easy way to install OpenCV on almost any OS. There has been made some tradeoffs especially regarding 3rd party dependencies. The current CentOS 5 environment is not the easiest to work with since it's quite old. This means that the maintenance burden becames overwhelming very fast if I enable every dependency or optimization OpenCV might have support for. Due to this a locally built OpenCV version will almost always have better performance than the one provided via this repository. |
I understand, but this is getting extreme. My own code runs in a few seconds with Fedora packages and also on Red Hat 7 with my own build based on the Fedora one. With opencv-python after one full hour it didn't finished. It might be time to consider dropping older platforms, the slowdown is getting unsustainable in my humble opinion. |
Perhaps |
I looked into the Fedora configs and also Lapack is on there while it's not enabled in And yes, manylinux2010 is the next step. |
And for completeness, since at this point CentOS 6 is already EOL, wanted to also reference |
It might be good to skip manylinux2010 and migrate straight to manylinux2014. |
I would agree. It's best practice to |
Could you check how the latest releases perform? |
Default configuration can have many differences from opencv-python, most obvious things are:
Other features/dependencies in opencv-python are similar to the default build configuration, including CPU optimizations (SSSE3 + all dispatching) and parallel-processing backend (pthreads). So it is important to localize performance drop: compare configs, measure execution time on different stages (input, processing, GUI), profile, etc.. |
Closing due to inactivity. |
Description of the problem
I notice running many different applications using opencv libraries are showing very significant performance difference when using the upstream python bindings vs. opencv-python. I verified this on Red Hat 7 and Fedora 30 / 31 Linux distributions. Fedora provides opencv python packages (3.4 series) which I also adapted to work on Red Hat Linux (modifying the RPM spec file to disable a couple of components not available in Red Hat).
When running the same code / applications slowdown is significant. Depending on the application it can take 3 to more than 10 longers. One of the tested application is: DeepLabCut. Switching only the opencv package and keeping the rest of the environment exactly the same, tripled the performance of our analysis time.
I tried to recompile the opencv-python locally using the setup.py and gcc-8 on CentOS 7, but it didn't make a big difference (there was a 10-20% improvement, but still very far away from the 300% observed with upstream build).
Looking at the cmake arguments in the RPM spec file and comparing it to the one in setup.py I cannot see anything that could explain the problem. I can see the Fedora RPM forces the use of OPENMP rather than using pthreads (and I understand opencv-python uses pthreads instead), not sure if this could be the primary cause of the issue. Sounds strange if it is though. I ran out of ideas and thought about opening this issue.
Expected behaviour
Same or close to same performance as upstream python bindings
Actual behaviour
Not entirely sure, but multiple applications are showing significant slowdowns when using this opencv-python rather than the upstream python binding
Steps to reproduce
Thank your for any help.
The text was updated successfully, but these errors were encountered: