Closed mikkac closed 1 year ago
Hi,
Your CPU usage is high because of OpenCV. We have seen reports about high CPU usage or slow processing and it's always because of OpenCV. That's why we use our own Computer Vision lib instead of OpenCV. We use OpenCV for prototyping but never in any commercial app. It's CPU and memory hungry.
On my PC with an RTX3060 and #16 cores, the benchmark app is at 150% (out of 1600%), it means 9% CPU usage
. If you think the high CPU usage is because of our SDK, then you have to write a sample code reproducing the issue WITHOUT any other 3rd-party lib. You should try the benchmark app.
This said, we do not support Tensorflow 2.11. The latest version supported is 2.6 (https://github.com/DoubangoTelecom/ultimateALPR-SDK/blob/master/samples/c++/README.md#migration-to-tensorflow-2x-and-cuda-11x).
We'll re-open the ticket if you can provide a sample code WITHOUT OpenCV producing high CPU usage. Please also note that the CPU will be used if you enable OpenVINO.
Hi, thanks for the response. I used OpenCV in my example code, based on official docs. However, as I pointed out, I checked CPU usage caused by OpenCV and it was ~80% CPU, so of course it should be subtracted from ~340% reported by top
.
I installed TensorFlow 2.6 and it indeed helped. CPU usage dropped significantly (most of it is now used by OpenCV) and GPU memory usage increased (as expected, ~2GB vRAM allocated by the process). So in case of RTX 3070 performance issue is no longer the case.
However, I also have PC with GTX 1050 Ti (nvidia-smi
output and hardware info below) and in this case, neither TF 1.14 nor TF 2.6 work well. CPU usage is still high and only ~40 MB of GPU's vRAM is allocated by the process.
Are there any additional tips regarding "older" hardware? Unfortunately all of our HW on production has those GPUs...
Here is the output from nvidia-smi
:
$ nvidia-smi
Tue Dec 13 12:47:46 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... On | 00000000:01:00.0 On | N/A |
| 0% 36C P8 N/A / 75W | 116MiB / 4096MiB | 4% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1041 G /usr/lib/xorg/Xorg 79MiB |
| 0 N/A N/A 1328 G /usr/bin/gnome-shell 21MiB |
| 0 N/A N/A 1848 G ...mviewer/tv_bin/TeamViewer 10MiB |
+-----------------------------------------------------------------------------+
Hardware info:
OS: Ubuntu 18.04.6 LTS x86_64
Host: H470M DS3H -CF
Kernel: 5.4.0-122-generic
Shell: bash 4.4.20
Resolution: 1280x1024
DE: GNOME 3.28.4
WM: GNOME Shell
CPU: Intel i5-10500 (12) @ 4.500GHz
GPU: NVIDIA GeForce GTX 1050 Ti Memory: 11502MiB / 15924MiB
Could you please share the full logs?
Sure: gtx_1050ti_tf_1_14.txt gtx_1050ti_tf_2_6.txt
Thanks
Hi, any updates on the issue?
*[COMPV INFO]: [UltAlprSdkEnginePrivate]recogn_tf_num_threads: 1, acceleration backend: null
*[COMPV INFO]: [UltOcrTensorflowSessionOptions] gpu_memory_alloc_max_percent = 0.100000
*[COMPV INFO]: [UltOcrTensorflowSessionOptions] Alloc session with gpu_memory_alloc_max_percent = 10%
*[COMPV INFO]: [UltOcrTensorflowSessionOptions] gpu_memory_alloc_max_percent = 0.100000
*[COMPV INFO]: [UltOcrTensorflowSessionOptions] Alloc session with gpu_memory_alloc_max_percent = 10%
... but you have a 4GB GPU, maybe that's too small. The 10% config was chosen for a 8GB GPU. Try adding to your JSON config:
{
"detect_tf_gpu_memory_alloc_max_percent": 0.4,
"pyramidal_search_tf_gpu_memory_alloc_max_percent": 0.2,
"recogn_tf_gpu_memory_alloc_max_percent": 0.4
}
Hi, I noticed that CPU usage is very high, even though I have discrete GPU and TensorFlow installed.
Here is all relevant information about my hardware:
With TensorFlow 1.14
I tried to use sample provided in the repository (both Python and C++), modified to see how the SDK works with video file (running
UltAlprSdkEngine::process
on each frame). Example code is available here. Basically, it's samplerecognizer.cxx
from this repository, but simplified (for readability) and modified to enable recognizing license plates from video. I explained how to run this code at the end of this description.Here are logs from first ~20 seconds of run.
nvidia-smi
output when running the demo:As you can see,
recognizer_video
is visible among GPU-associated processes. Nevertheless, CPU usage is still high:Of course I checked what is the resource usage caused only by reading and displaying frame with
OpenCV
and it's around ~80% CPU, so there is still a lot usage caused by the SDK.With TensorFlow 2.11
Based on information in #265 I installed TensorFlow 2 (2.11 is the latest version). I did the "trick" with satisfying
ldd libultimate_alpr-sdk.so
described here, but unfortunately I encountered runtime crash caused by:Full log is available here
⚠️ Is there anything else I can check/tweak to decrease CPU usage?
=====================================================
How to run example code
OpenCV
. I builtmaster
from the official repository..cxx
fileVideo file I used is available here.