{"action":"created","issue":{"url":"https://api.github.com/repos/tesseract-ocr/tesseract/issues/71","labels_url":"https://api.github.com/repos/tesseract-ocr/tesseract/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/tesseract-ocr/tesseract/issues/71/comments","events_url":"https://api.github.com/repos/tesseract-ocr/tesseract/issues/71/events","html_url":"https://github.com/tesseract-ocr/tesseract/issues/71","id":98339817,"number":71,"title":"OS X Yosemite with OpenCL: --enable-opencl now compiles but OCR fails","user":{"login":"jbarlow83","id":1825843,"avatar_url":"https://avatars.githubusercontent.com/u/1825843?v=3","gravatar_id":"","url":"https://api.github.com/users/jbarlow83","html_url":"https://github.com/jbarlow83","followers_url":"https://api.github.com/users/jbarlow83/followers","following_url":"https://api.github.com/users/jbarlow83/following{/other_user}","gists_url":"https://api.github.com/users/jbarlow83/gists{/gist_id}","starred_url":"https://api.github.com/users/jbarlow83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbarlow83/subscriptions","organizations_url":"https://api.github.com/users/jbarlow83/orgs","repos_url":"https://api.github.com/users/jbarlow83/repos","events_url":"https://api.github.com/users/jbarlow83/events{/privacy}","received_events_url":"https://api.github.com/users/jbarlow83/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-07-31T08:13:52Z","updated_at":"2015-08-31T14:48:13Z","closed_at":null,"body":"It seems that any OpenCL operation on my OS X Yosemite machine triggers attempts to allocate extremely large memory blocks and allocation failures.\r\n\r\nThe size of the attempted allocation is 1125865547108352 bytes or in hex, 0x3fff800001000, which looks special.\r\n\r\nOpenCL otherwise works on my machine. I use the Python OpenCV library and a commercial application that uses OpenCL.\r\n\r\nAside from whatever is happening here, it also looks like a bug that the profile data gets written even if OpenCL fails. I highly doubt my graphics card and processor give identical performance so it looks some invalid calculation takes place and the results are then saved.\r\n\r\n## Testing --list-langs\r\n\r\nChecking for languages in an OpenCL binary:\r\n```\r\nset -x TESSDATA_PREFIX /usr/local/Cellar/tesseract/3.03rc1_3/share   # Homebrew tesseract 3.03\r\n/opt/tesseract-opencl/bin/tesseract --list-langs\r\n```\r\n\r\nResults\r\n\r\n```\r\n[DS] Profile file not available (tesseract_opencl_profile_devices.dat); performing profiling.\r\n\r\n[DS] Device: \"Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz\" (OpenCL) evaluation...\r\ntesseract(9135,0x7fff7a778300) malloc: *** mach_vm_map(size=1125865547108352) failed (error code=3)\r\n*** error: can't allocate region\r\n*** set a breakpoint in malloc_error_break to debug\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannels .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannelsReduction .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_ThresholdRectToPix .\r\n[DS] Device: \"Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz\" (OpenCL) evaluated\r\n[DS]          composeRGBPixel: 1540962513.969949 (w=1.2)\r\n[DS]            HistogramRect: 1540962513.969949 (w=2.4)\r\n[DS]       ThresholdRectToPix: 1540962513.969949 (w=4.5)\r\n[DS]        getLineMasksMorph: 1204940900.030019 (w=5.0)\r\n[DS]                    Score: 18506500096.000000\r\n\r\n[DS] Device: \"GeForce GT 755M\" (OpenCL) evaluation...\r\ntesseract(9135,0x7fff7a778300) malloc: *** mach_vm_map(size=1125865547108352) failed (error code=3)\r\n*** error: can't allocate region\r\n*** set a breakpoint in malloc_error_break to debug\r\n[DS] Device: \"GeForce GT 755M\" (OpenCL) evaluated\r\n[DS]          composeRGBPixel: 1540962513.969949 (w=1.2)\r\n[DS]            HistogramRect: 1540962513.969949 (w=2.4)\r\n[DS]       ThresholdRectToPix: 1540962513.969949 (w=4.5)\r\n[DS]        getLineMasksMorph: 1204940900.030019 (w=5.0)\r\n[DS]                    Score: 18506500096.000000\r\n\r\n[DS] Device: \"(null)\" (Native) evaluation...\r\n[DS] Device: \"(null)\" (Native) evaluated\r\n[DS]          composeRGBPixel: 256.000000 (w=1.2)\r\n[DS]            HistogramRect: 256.000000 (w=2.4)\r\n[DS]       ThresholdRectToPix: 256.000000 (w=4.5)\r\n[DS]        getLineMasksMorph: 4294966736.000000 (w=5.0)\r\n[DS]                    Score: 21474836480.000000\r\n[DS] Scores written to file (tesseract_opencl_profile_devices.dat).\r\n[DS] Device[1] 1:Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz score is 18506500096.000000\r\n[DS] Device[2] 1:GeForce GT 755M score is 18506500096.000000\r\n[DS] Device[3] 0:(null) score is 21474836480.000000\r\n[DS] Selected Device[1]: \"Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz\" (OpenCL)\r\ntesseract(9135,0x7fff7a778300) malloc: *** mach_vm_map(size=1125865547108352) failed (error code=3)\r\n*** error: can't allocate region\r\n*** set a breakpoint in malloc_error_break to debug\r\nList of available languages (2):\r\neng\r\nosd\r\n```\r\n\r\nSubsequent executions try to use the OpenCL profile results but still get errors:\r\n```\r\n[DS] Profile read from file (tesseract_opencl_profile_devices.dat).\r\n[DS] Device[1] 1:Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz score is 18506500096.000000\r\n[DS] Device[2] 1:GeForce GT 755M score is 18506500096.000000\r\n[DS] Device[3] 0:(null) score is 21474836480.000000\r\n[DS] Selected Device[1]: \"Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz\" (OpenCL)\r\ntesseract(9139,0x7fff7a778300) malloc: *** mach_vm_map(size=1125865547108352) failed (error code=3)\r\n*** error: can't allocate region\r\n*** set a breakpoint in malloc_error_break to debug\r\nList of available languages (2):\r\neng\r\nosd\r\n```\r\n\r\n## Testing OCR of JPEG to PDF\r\n\r\n\r\n```\r\nset -x TESSDATA_PREFIX /usr/local/Cellar/tesseract/3.03rc1_3/share   # Homebrew tesseract 3.03\r\n/opt/tesseract-opencl/bin/tesseract tests/resources/congress.jpg tessopencl -l eng pdf\r\n```\r\n\r\nResult:\r\n\r\n```\r\nTesseract Open Source OCR Engine v3.04.01dev with Leptonica\r\n[DS] Profile file not available (tesseract_opencl_profile_devices.dat); performing profiling.\r\n\r\n[DS] Device: \"Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz\" (OpenCL) evaluation...\r\ntesseract(9120,0x7fff7a778300) malloc: *** mach_vm_map(size=1125865547108352) failed (error code=3)\r\n*** error: can't allocate region\r\n*** set a breakpoint in malloc_error_break to debug\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannels .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannelsReduction .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_ThresholdRectToPix .\r\n[DS] Device: \"Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz\" (OpenCL) evaluated\r\n[DS]          composeRGBPixel: 1539474209.312102 (w=1.2)\r\n[DS]            HistogramRect: 1539474209.312102 (w=2.4)\r\n[DS]       ThresholdRectToPix: 1539474209.312102 (w=4.5)\r\n[DS]        getLineMasksMorph: 1345623668.687865 (w=5.0)\r\n[DS]                    Score: 19197859840.000000\r\n[DS] Device: \"GeForce GT 755M\" (OpenCL) evaluation...\r\ntesseract(9120,0x7fff7a778300) malloc: *** mach_vm_map(size=1125865547108352) failed (error code=3)\r\n*** error: can't allocate region\r\n*** set a breakpoint in malloc_error_break to debug\r\n[DS] Device: \"GeForce GT 755M\" (OpenCL) evaluated\r\n[DS]          composeRGBPixel: 1539474209.312102 (w=1.2)\r\n[DS]            HistogramRect: 1539474209.312102 (w=2.4)\r\n[DS]       ThresholdRectToPix: 1539474209.312102 (w=4.5)\r\n[DS]        getLineMasksMorph: 1345623668.687865 (w=5.0)\r\n[DS]                    Score: 19197859840.000000\r\n\r\n[DS] Device: \"(null)\" (Native) evaluation...\r\n[DS] Device: \"(null)\" (Native) evaluated\r\n[DS]          composeRGBPixel: 256.000000 (w=1.2)\r\n[DS]            HistogramRect: 256.000000 (w=2.4)\r\n[DS]       ThresholdRectToPix: 256.000000 (w=4.5)\r\n[DS]        getLineMasksMorph: 4294966736.000000 (w=5.0)\r\n[DS]                    Score: 21474836480.000000\r\n[DS] Scores written to file (tesseract_opencl_profile_devices.dat).\r\n[DS] Device[1] 1:Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz score is 19197859840.000000\r\n[DS] Device[2] 1:GeForce GT 755M score is 19197859840.000000\r\n[DS] Device[3] 0:(null) score is 21474836480.000000\r\n[DS] Selected Device[1]: \"Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz\" (OpenCL)\r\ntesseract(9120,0x7fff7a778300) malloc: *** mach_vm_map(size=1125865547108352) failed (error code=3)\r\n*** error: can't allocate region\r\n*** set a breakpoint in malloc_error_break to debug\r\nWarning in pixReadMemJpeg: work-around: writing to a temp file\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannels .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannelsReduction .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_ThresholdRectToPix .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannels .\r\nOpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannelsReduction .\r\n```\r\n\r\n## Versions\r\n\r\n```\r\ntesseract 3.04.01dev\r\n leptonica-1.71\r\n  libgif 4.1.6(?) : libjpeg 8d : libpng 1.6.18 : libtiff 4.0.4 : zlib 1.2.5\r\n\r\n OpenCL info:\r\n  Found 1 platforms.\r\n  Platform name: Apple.\r\n  Version: OpenCL 1.2 (May 10 2015 19:38:45).\r\n  Found 2 devices.\r\n    Device 1 name: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz.\r\n    Device 2 name: GeForce GT 755M.\r\n```"},"comment":{"url":"https://api.github.com/repos/tesseract-ocr/tesseract/issues/comments/136395480","html_url":"https://github.com/tesseract-ocr/tesseract/issues/71#issuecomment-136395480","issue_url":"https://api.github.com/repos/tesseract-ocr/tesseract/issues/71","id":136395480,"user":{"login":"pedrocicoleme","id":1869248,"avatar_url":"https://avatars.githubusercontent.com/u/1869248?v=3","gravatar_id":"","url":"https://api.github.com/users/pedrocicoleme","html_url":"https://github.com/pedrocicoleme","followers_url":"https://api.github.com/users/pedrocicoleme/followers","following_url":"https://api.github.com/users/pedrocicoleme/following{/other_user}","gists_url":"https://api.github.com/users/pedrocicoleme/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrocicoleme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrocicoleme/subscriptions","organizations_url":"https://api.github.com/users/pedrocicoleme/orgs","repos_url":"https://api.github.com/users/pedrocicoleme/repos","events_url":"https://api.github.com/users/pedrocicoleme/events{/privacy}","received_events_url":"https://api.github.com/users/pedrocicoleme/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T14:48:13Z","updated_at":"2015-08-31T14:48:13Z","body":"I tried both master and 3.04.00 with `--enable-opencl` on Ubuntu with Catalyst 15.7 and for my two devices (FX8120 and R9 285) the OCR also outputs a .txt but the content is only empty lines and some wrong characters. Forcing to run without opencl achieves the correct output.\r\n\r\nWhen running with OpenCL on FX8120 there are no warnings or errors during execution, but there are some warnings as `tiff page not found` and `box outside rectangle` on R9 285. In the end, the (wrong) output is the same for any of them."}}