thqby / ahk2_lib

MIT License
222 stars 31 forks source link

RapidOcrOnnx.dll GPU support #60

Closed Qriist closed 1 month ago

Qriist commented 1 month ago

Hey there thqby! Is your provided RapidOcrOnnx.dll compiled with GPU support? If it is, how do I tell it to use the GPU? If not, would you please consider doing so?

I've been trying to compile the dll myself but I can't get the prerequisites to install and I have no idea how to solve the errors I'm getting.

Thanks!

thqby commented 1 month ago

The current version supports only CPUs. I have tested the directml version on my computer, but no performance advantage.

Qriist commented 1 month ago

The current version supports only CPUs. I have tested the directml version on my computer, but no performance advantage.

Ah that's unfortunate. Thanks for checking it out for me.

In that same vein, are you sure that you compiled the the dll with multithreading enabled?

I ran the following code with a variety of threads values:

#Requires AutoHotkey v2.0
#Include <RapidOcr>

image := "1.bmp"
threads := 999

param := RapidOcr.OcrParam()
param.doAngle := false

ocr := RapidOcr({ models: A_ScriptDir "\models", numThread: threads },A_ScriptDir "\RapidOcrOnnx.dll")

num := 100
loop num{
    ToolTip(Round((a_index / num)*100,2) "%")
    ocr.ocr_from_file(image, param?)
}

I've tried 1,2,4,6,8, and 999 threads, but all of them gave extremely similar (within milliseconds) results. The time varies a little bit per image, but never per thread value per given image. That suggests that the DLL isn't actually running multithreaded. Am I doing something wrong?

thqby commented 1 month ago

After applying this commit https://github.com/RapidAI/RapidOcrOnnx/commit/83886d188058633b806258908e25c4aff7e4ee24, on my computer, the number of threads is set to 2 or 3 for the fastest recognition.

Qriist commented 1 month ago

I appreciate you looking into that!

thqby commented 1 month ago

RapidOcrOnnx.zip

Requires onnxruntime-gpu v1.18.0, cuda 12.x, cudnn 8.x