-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization (/O2) option causes a run time error. #2898
Comments
Maybe you created code which uses AVX instructions, and the computer which crashes does not support AVX? |
@stweil I'm not experienced in c++; and have no idea if it uses AVX instructions. I've used the steps described in the help and some description in the issues to build libtesseract. However, that computer has this CPU. I guess it supports AVX. Intel® Xeon® Processor E5-1620 v2 |
Disabling optimization decreases performance drastically. Any help is very appreciated. |
You can try other optimization options: https://docs.microsoft.com/en-us/cpp/build/reference/o-options-optimize-code?view=vs-2019 In general, we can't really help you here unless you reproduce the issue with the command line or submit a C/C++ code that uses the API. |
@amitdo thank you for your response. Performance has a great importance for our use. So I have to use /O2. Using only /Ot did not increase the performance like /O2 did (my previous comment) This is the code that generates the error. I've tried it with latest Tessdata best and fast of TUR + ENG languages.
To solve the issue I've used this way:
Now, I realized I haven't tried to build debug dll with optimization, and debug c++ to see what is generating error.. I'll try it now.. Edit: I've tried. Project could not be built with any optimization enabled in debug mode: cl : command line error D8016: '/O2' and '/RTC1' command-line options are incompatible |
I'm not a Windows developer, but just by reading Microsoft's docs, it's clear to me that /RTC1 is not the 'debug mode'. This one is probably the flag you want: |
You said you run it remotely, there were some bug reports related to VM + AVX / AVX2. |
I'm not a C++ developer but, when the libtesseract is built in debug mode, RTC1 is active, and it does not let the project be compiled while an optimization is active. As far as I could understand from: I'm not remotely running Tesseract; it runs on a remote machine, which is not a VM. I just remotely debug it. Three extra notes:
I hope these make any sense. Thank you in advance. |
You said:
but you also added:
which shows '/Od + /Ot'. So, did you try just /Ot without /Od?
Still, I suggest to check if the issue also occurs with /O1 (without /Od or any other /O). |
Yes, using /Ot no issue occurred but the performance was bad.
I tried O1 and the issue occurred. I've tried many other combinations but could not resolve the issue with the optimization performance boost. I don't have an access to that computer anymore, so I cannot make any tries. I've solved this issue by using 2 different dll's, one optimized, one not. C# code tries the optimized dll first; if it's not successful it uses the not optimized one. No performance or error issue has been reported since. This might be a very special case of a single computer. I have no idea. So closing this issue might be a better option, if the info I've provided here doesn't help much. |
Without a stack trace of the crash there is no chance to do more here. |
I have pulled the latest code (today). Using Visual Studio 2019 (in Windows 10) built the project in Release x64. Everything works fine in many computers. However in one computer, when I try to OCR any image, an error occurs. The computer is Windows 10 64bit and has 16GB RAM. There is nothing unusual in the OS and is up to date. I cannot see the message of the error, because I use your library from C#. The error can only be caught as SEHException, which does not tell anything about the error. I've built the the libtesseract project in debug mode to see the error details, and debugged on that computer. No exception occurred, the OCR finished successfully in debug mode.
In the libtesseract project: I've changed
Configuration Properties / C/C++ / Optimization / Optimization value from Maximum Optimization (Favor Speed) (/O2) to Disabled (/Od)
and no error occurred; OCR processes finished with success.
The text was updated successfully, but these errors were encountered: