librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

python wrappers is consuming 100% of my CPU

Open Taprik opened this issue 8 years ago • 8 comments

Required Info
Camera Model SR300
Firmware Version 3.21.0.0
Operating System & Version windows 10
Kernel Version (Linux Only)
SDK Version 2.0

I managed to compile a x64 binaries for python 3.6 x64. and then I use the dll provided with the sdk. The curious thing is that getting and displaying the color stream is consuming all my cpu. When I use the intel viewer it needs 22% of the cpu. When I use the script opencv_viewer_example it needs most all the cpu. The definition use in this script changes nothing (the same with 640 x 480) Is there a way to have a descent cpu consumption with python. By the way I need to have it works in x64 as I have other lib only working with python 3.6 x64 ... I attach two screen capture, one with the intel_viewer intel_viewer the other with python script (found in the examples folder) python_viewer

Taprik avatar Jan 07 '18 19:01 Taprik

Hi @Taprik , I marked this as a bug to further investigate the issue, and since I think we need the examples to provide a solution if required. This is not a python issue, it is easily reproducible running the same code in C++ (or even the rs-capture example). The viewer is not using the pipeline, and uses a number of message queues which is probably the cause of difference. After we investigate we will post the results.

zivsha avatar Jan 08 '18 21:01 zivsha

@zivsha Is it related to #744 ? Wouldn't it be good to release a version with OpenMP disabled?

Jiloc avatar Jan 16 '18 18:01 Jiloc

Hi @Jiloc , we haven't got around to investigate this but OpenMP is a potential high CPU consumer. The python wrapper is available for self build and you can disable openMP via CMake. I'll propose providing a version without OpenMP in the future.

zivsha avatar Jan 16 '18 22:01 zivsha

I confirm that building with openMP to false solve the problem

Taprik avatar Jan 20 '18 10:01 Taprik

I could reproduce this problem in C++ with the official 2.9.0 release but noticed 2 interesting things:

  • 100% CPU usage when streaming depth + color but only minimal CPU usage when streaming only depth or depth + infrared
  • recompiling from source with OpenMP disabled: minimal CPU usage for depth + color (recompile with OpenMP enabled 100% usage again)

Note that I installed 2.9.0 using the installer executable on Windows 10 and for source compilation I used the latest GitHub version (20th January)

Brekel avatar Jan 20 '18 12:01 Brekel

@Brekel We use OpnMP to convert the color-stream's format from YUY to RGB, so your insights look reasonable

zivsha avatar Jan 21 '18 12:01 zivsha

[Realsense Customer Engineering Team Comment] @Taprik Can we close this issue now?

Yes you can. Thanks a lot !

Taprik avatar Feb 28 '18 07:02 Taprik