Giter Site home page Giter Site logo

OpenCL segfault about tesseract HOT 14 CLOSED

tesseract-ocr avatar tesseract-ocr commented on April 27, 2024
OpenCL segfault

from tesseract.

Comments (14)

jbreiden avatar jbreiden commented on April 27, 2024

Ray says,

I think there is a bug in InitDSProfile.

I suspect if you change if (status == SUCCESS) to if (status == SUCCESS && profile->numDevices > 0)
at openclwrapper.cpp:3426
then it will work. (You have no devices, and unlike the code here: https://docs.libreoffice.org/opencl/html/opencl__device__selection_8h_source.html
it doesn't correctly always add the native CPU as a device, and therefore attempts to write a null buffer, even though it has no devices.)

from tesseract.

jbreiden avatar jbreiden commented on April 27, 2024

still trouble

from tesseract.

jbreiden avatar jbreiden commented on April 27, 2024

note that if we get through this, I will probably enable OpenCL by default for Debian/Ubuntu

from tesseract.

spSerg avatar spSerg commented on April 27, 2024

I'm in stuck. How this code (located at oclkernels.h:1086) can work:

pixels.v[i] = imageData[
    w*(BURSTS_PER_WORD*(PIXELS_PER_BURST*NUM_CHANNELS)/CHAR_VEC_WIDTH) + 
    b*((PIXELS_PER_BURST*NUM_CHANNELS)/CHAR_VEC_WIDTH)  + i];

where maximum value of index can be 4x higher that size of imageData array
Variables are:
w in range [0 .. count of DWORDS in image),
b in range [0 .. BURSTS_PER_WORD),
i in range [0 .. (PIXELS_PER_BURST*NUM_CHANNELS)/CHAR_VEC_WIDTH )
Constants values:

#define NUM_CHANNELS 4
#define CHAR_VEC_WIDTH 8
#define PIXELS_PER_WORD 32
#define PIXELS_PER_BURST 8
#define BURSTS_PER_WORD (PIXELS_PER_WORD/PIXELS_PER_BURST)

from tesseract.

jbreiden avatar jbreiden commented on April 27, 2024

I get a similar looking segfault (but I didn't confirm with gdb) even on a computer that contains a discrete graphics card. Is OpenCL working for anyone at all?

from tesseract.

zdenop avatar zdenop commented on April 27, 2024

it worked for me on some images (there are some issues reported already - IMO 2 color tiff should work). Last week it segfault on linux. I will try windows today...
Also on forum there are some experiments[1]
[1] https://mail.google.com/mail/u/0/#search/opencl

from tesseract.

spSerg avatar spSerg commented on April 27, 2024

I can't get fully worked OpenCL configuration. But I have a much different environment (without any other dependencies except leptonica). I've got errors like:
Access violation reading location 0x58B87000
That's a position after imageData host's buffer.

from tesseract.

zdenop avatar zdenop commented on April 27, 2024

I am not sure what do you mean with "any other dependencies except leptonica" - to run tesseract with opencl support you need libtiff and opencl sdk that support your hardware...

from tesseract.

zdenop avatar zdenop commented on April 27, 2024

@jbreiden:
it works for me on windows:
tesseract-opencl.exe ....\testing\phototest.tif -
[OD] Load opencl.dll successful!
[DS] Profile file not available (tesseract_opencl_profile_devices.dat); performi
ng profiling.

[DS] Device: "Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz" (OpenCL) evaluation...
[OD] write binary[kernel-Intel(R)_Core(TM)i7-4800MQ_CPU@_2.70GHz.bin] succesfully
[DS] Device: "Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz" (OpenCL) evaluated
[DS] composeRGBPixel: 0.038657 (w=1.2)
[DS] HistogramRect: 0.325462 (w=2.4)
[DS] ThresholdRectToPix: 0.042622 (w=4.5)
[DS] getLineMasksMorph: 0.119543 (w=5.0)
[DS] Score: 1.617007

[DS] Device: "Intel(R) HD Graphics 4600" (OpenCL) evaluation...
[OD] write binary[kernel-Intel(R)_HD_Graphics_4600.bin] succesfully
[DS] Device: "Intel(R) HD Graphics 4600" (OpenCL) evaluated
[DS] composeRGBPixel: 0.153912 (w=1.2)
[DS] HistogramRect: 0.449184 (w=2.4)
[DS] ThresholdRectToPix: 0.048737 (w=4.5)
[DS] getLineMasksMorph: 0.027403 (w=5.0)
[DS] Score: 1.619068

[DS] Device: "(null)" (Native) evaluation...
[DS] Device: "(null)" (Native) evaluated
[DS] composeRGBPixel: 0.088750 (w=1.2)
[DS] HistogramRect: 0.388795 (w=2.4)
[DS] ThresholdRectToPix: 0.182945 (w=4.5)
[DS] getLineMasksMorph: 0.613772 (w=5.0)
[DS] Score: 4.931717
[DS] Scores written to file (tesseract_opencl_profile_devices.dat).
[DS] Device[1] 1:Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz score is 1.617007
[DS] Device[2] 1:Intel(R) HD Graphics 4600 score is 1.619068
[DS] Device[3] 0:(null) score is 4.931717
[DS] Selected Device[1]: "Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz" (OpenCL)
Page 1
This is a lot of 12 point text to test the
ocr code and see if it works on all types
of file format.

The quick brown dog jumped over the
lazy fox. The quick brown dog jumped
over the lazy fox. The quick brown dog
jumped over the lazy fox. The quick
brown dog jumped over the lazy fox.

from tesseract.

spSerg avatar spSerg commented on April 27, 2024

Just made a bit changes to exclude libtiff dependency.
I have my own input and output streams.
I see, that I can't request any attention without prepare reproducible error in your environment.

from tesseract.

jbreiden avatar jbreiden commented on April 27, 2024

spSerg: you can request attention, but if we can't reproduce you need to supply more information, such as a backtrace from gdb or the output of valgrind (either works much better when ./configure is run with --enable-debug)

from tesseract.

jbreiden avatar jbreiden commented on April 27, 2024

I'm having an unexpectedly hard time with this.

from tesseract.

jbreiden avatar jbreiden commented on April 27, 2024
#0  strlen () at ../sysdeps/x86_64/strlen.S:106
#1  0x00007ffff77d3c5f in writeProfileToFile (profile=0x80ac20, 
    serializer=0x7ffff77dcc45 <serializeScore(ds_device*, void**, unsigned int*)>, 
    file=0x7ffff78a0b20 "tesseract_opencl_profile_devices.dat") at opencl_device_selection.h:268
#2  0x00007ffff77dd11f in OpenclDevice::getDeviceSelection () at openclwrapper.cpp:3427
#3  0x00007ffff77d5a6c in OpenclDevice::InitOpenclRunEnv_DeviceSelection (argc=0) at openclwrapper.cpp:527
#4  0x00007ffff77d578a in OpenclDevice::InitEnv () at openclwrapper.cpp:431
#5  0x00007ffff75efb2f in tesseract::TessBaseAPI::Init (this=0x7fffffffd9f0, datapath=0x0, 
    language=0x405a13 "eng", oem=tesseract::OEM_DEFAULT, configs=0x7fffffffe650, configs_size=0, 
    vars_vec=0x7fffffffd9b0, vars_values=0x7fffffffd9d0, set_only_non_debug_params=false) at baseapi.cpp:299
#6  0x0000000000404327 in main (argc=3, argv=0x7fffffffe638) at tesseractmain.cpp:181

from tesseract.

zdenop avatar zdenop commented on April 27, 2024

Please check master branch or commits f46dfdc and 5db7602.

from tesseract.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.