rknn-toolkit2 icon indicating copy to clipboard operation
rknn-toolkit2 copied to clipboard

RKNNLite API Inferencing Slow Compared to C++

Open Eliasin opened this issue 1 year ago • 4 comments

Hi,

I noticed that during my testing, inferencing YOLOv8n with the rknnlite API seems to be much slower than using the C API for inferencing. I measured the time taken like this

        start_time = time.time()
        outputs = self.rknn_lite.inference(inputs=[frame])
        end_time = time.time()
        print(f"Inference duration: {end_time - start_time}")

and found that the times were around ~300 ms when the C version has inference times of around 20 ms on the Rk3588. I am using the 1.6.0 version of librknnrt and an unmodified, converted YOLOv8n model from rknn_model_zoo.

Eliasin avatar Feb 23 '24 18:02 Eliasin

hii @Eliasin , could you please share the details of C api any reference code or document. I want to use it for ResNet inference.

shubhambfw avatar Apr 30 '24 09:04 shubhambfw

hii @Eliasin , could you please share the details of C api any reference code or document. I want to use it for ResNet inference.

The C api reference consists of a pdf, here is a link.

Eliasin avatar May 01 '24 20:05 Eliasin

fyi time.time() gives weird results which is why time.perf_counter exists for timing code executions

jdchmiel avatar Jun 15 '24 20:06 jdchmiel

hii @Eliasin , could you please share the details of C api any reference code or document. I want to use it for ResNet inference.

The C api reference consists of a pdf, here is a link.

Hello, have you solved this issue? I've encountered something similar on the RK3576. I haven't yet compared the inference time differences between the C++ and Python APIs. However, I've noticed that the inference time on the Python board is almost three times slower compared to connected board inference. The FPS in connected board inference is similar to what's listed in the rknn model zoo, but direct Python inference on the board is three times slower. I've already ruled out factors such as model pre-processing, post-processing, and frame reading.

Leo5050xvjf avatar Aug 05 '24 05:08 Leo5050xvjf