larq / compute-engine

Highly optimized inference engine for Binarized Neural Networks
https://docs.larq.dev/compute-engine
Apache License 2.0
240 stars 33 forks source link

core dumped when number of threads is larger than 2 #730

Closed godhj93 closed 2 years ago

godhj93 commented 2 years ago

Hi all,

I'm testing my BNN model on Raspyberry PI and Jetson XAVIER CPU using benchamark tool.

When I try to test it with --num_threads>2 option it is terminated and says as:

hj@xavier:~$ ./lce_benchmark_model_aarch64 --graph=BDN_45_Encoder_256_64.tflite 
STARTING!
Log parameter values verbosely: [0]
Graph: [BDN_45_Encoder_256_64.tflite]
Loaded model BDN_45_Encoder_256_64.tflite
The input model file size (MB): 4.80795
Initialized session in 5.373ms.
Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
count=3 first=206847 curr=207657 min=174807 max=207657 avg=196437 std=15298

Running benchmark for at least 50 iterations and at least 1 seconds but terminate if exceeding 150 seconds.
count=50 first=205194 curr=196761 min=195713 max=205852 avg=198612 std=2465

Inference timings in us: Init: 5373, First inference: 206847, Warmup (avg): 196437, Inference (avg): 198612
Note: as the benchmark tool itself affects memory footprint, the following is only APPROXIMATE to the actual memory footprint of the model at runtime. Take the information at your discretion.
Peak memory footprint (MB): init=1.47266 overall=30.4531
hj@xavier:~$ ./lce_benchmark_model_aarch64 --graph=BDN_45_Encoder_256_64.tflite --num_threads=2
STARTING!
Log parameter values verbosely: [0]
Num threads: [2]
Graph: [BDN_45_Encoder_256_64.tflite]
#threads used for CPU inference: [2]
Loaded model BDN_45_Encoder_256_64.tflite
The input model file size (MB): 4.80795
Initialized session in 3.739ms.
Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
terminate called without an active exception
Aborted (core dumped)

Is there any solution?

Many Thanks.

CNugteren commented 2 years ago

Thanks for reporting the issue. Actually, we noticed this bug a while ago but forgot to report an issue, sorry about that.

The good news is that this should already be fixed in the latest main branch since 5 days, see https://github.com/larq/compute-engine/pull/727. We will soon release a new version of the larq-compute-engine with the fixed binaries. Until then you can compile them yourself from the latest sources, e.g.:

bazelisk build //larq_compute_engine/tflite/benchmark:lce_benchmark_model --config=aarch64 -c opt --copt=-O3
CNugteren commented 2 years ago

We have just made a new release (v0.7.0), which has pre-compiled binaries that should no longer suffer from this issue. Could you try it out and confirm by closing this issue? Thanks!

godhj93 commented 2 years ago

I tested it again and It works well on AGX Xavier! Thanks!