Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to disable openmp when using tesseract api?

49 views
Skip to first unread message

Xingtong Chen

unread,
Dec 18, 2024, 12:43:39 AM12/18/24
to tesseract-ocr
In tesseract document, I found that if I need to disable multithread, I need the configure option

../../configure --disable-openmp

This works well on my machine.

But I still cannot figure out how to disable multithread tesseract when using teseract api.

I have tried -DOPENMP_SIMD_FALSE, but this didn't work. Is there any compile flag to disable openmp?

I use g++ compiler with version "gcc version 12.2.0 (Debian 12.2.0-14)".

Zdenko Podobny

unread,
Dec 18, 2024, 1:43:21 AM12/18/24
to tesser...@googlegroups.com
So you build the tesseract library without openmp, but when you use it (by calling api) multithreading is there?
Do I understand you correctly? How did you find it out?

Zdenko


st 18. 12. 2024 o 6:43 Xingtong Chen <chenxt...@gmail.com> napísal(a):
--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/tesseract-ocr/554ec663-9411-4844-8fbf-8939c84fe594n%40googlegroups.com.
Message has been deleted

Xingtong Chen

unread,
Dec 18, 2024, 3:51:34 AM12/18/24
to tesseract-ocr
Apologize for my unclear expression. There are 2 tesseracts on my machine:

1. One is built from the github release (5.5.0). I use the  --disable-openmp  flag to conigure and I get a build without multithread.

2. I install libtesseract5 (5.3.0-2 amd64) from debian apt and the api head file is in my /usr/include folder. I compile a demo using g++ with version  “gcc version 12.2.0 (Debian 12.2.0-14)”.When I run the executable file, the process use 4 threads on my machine.

I find it by checking htop command results.

I just tried using OpenMP to perform multithreaded recognition operations with tesseract::TessBaseAPI* (using libtesseract5), but it seems the multithreading effect has disappeared.  That's weird to me.

Thank you for your patience ;)

Zdenko Podobny

unread,
Dec 18, 2024, 5:19:55 AM12/18/24
to tesser...@googlegroups.com
You limit number of used threads by environment variable. E.g. set before running demo program this:

set OMP_NUM_THREADS=1

or use omp_set_num_threads[1] function within your program.




Zdenko


st 18. 12. 2024 o 9:50 Xingtong Chen <chenxt...@gmail.com> napísal(a):
Apologize for my unclear expression. There are 2 tesseracts on my machine:

1. One is built from the github release (5.5.0). I use the  --disable-openmp  flag to conigure and I get a build without multithread.

2. I install libtesseract5 (5.3.0-2 amd64) from debian apt and the api head file is in my /usr/include folder. I compile a demo using g++ with version  “gcc version 12.2.0 (Debian 12.2.0-14)”.When I run the executable file, the process use 4 threads on my machine.

I find it by checking htop command results.

I just tried using OpenMP to perform multithreaded recognition operations with tesseract::TessBaseAPI* (using libtesseract5), but it seems the multithreading effect has disappeared.  That's weird to me.

Thank you for your patience ;)

在2024年12月17日星期二 UTC-8 22:43:21<zdenop> 写道:

Xingtong Chen

unread,
Dec 18, 2024, 5:38:04 AM12/18/24
to tesseract-ocr
omp_set_num_threads(1) in demo main function doesn't seem to work, but I think using omp to multithread running tesseract works.

Thanks. ;)

Reply all
Reply to author
Forward
0 new messages