Good morning all!!!
I've had trouble with easyocr
in raspberry pi 4
running ubuntu 22.04LTS
.
All installed using pip
(pip install torch, torchvision, opencv-python, opencv-contrib-python, easyocr
).
Kernel crashes with: reader = easyocr.Reader(['pt'], gpu=False)
Output is:
EasyOCR is crashing the Python 3.10 VM
Ubuntu 22.04 / Debian Bullseye (identical problem but Python 3.9)
Architecture Raspberry Pi 4 4GBytes
Error as follows:
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import faulthandler
import easyocr
faulthandler.enable()
reader = easyocr.Reader(['pt'])
Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.
Fatal Python error: Segmentation fault
Current thread 0x0000ffff949d3420 (most recent call first):
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/_ops.py", line 692 in call
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 119 in init
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 400 in init
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 291 in from_float
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 495 in from_float
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 623 in swap_module
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 590 in _convert
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 588 in _convert
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 588 in _convert
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 550 in convert
File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 465 in quantize_dynamic
File "/home/cdab63/.local/lib/python3.10/site-packages/easyocr/recognition.py", line 177 in get_recognizer
File "/home/cdab63/.local/lib/python3.10/site-packages/easyocr/easyocr.py", line 231 in init
File "", line 1 in
Extension modules: PIL._imaging, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, torch._C, torch._C._fft, torch._C._linalg, torch._C._nested, torch._C._nn, torch._C._sparse, torch._C._special, PIL._imagingft, cv2.cv2, scipy._lib._ccallback_c, scipy.ndimage._nd_image, scipy.special._ufuncs_cxx, scipy.special._ufuncs, scipy.special._specfun, scipy.special._comb, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg.cython_lapack, scipy.linalg._cythonized_array_utils, scipy.linalg._solve_toeplitz, scipy.linalg._decomp_lu_cython, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.sparse.linalg._isolve._iterative, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.linalg._flinalg, scipy.special._ellip_harm_2, _ni_label, scipy.ndimage._ni_label, skimage._shared.geometry, yaml._yaml (total: 58)
Segmentation fault (core dumped)
As it was running before, without such errors, I tried to reinstall everything, with no effects. That included reinstalling the whole ubuntu.
Problem fixed by retrofitting both torch and torchvision. torch==2.0.1 torchvision==0.15.2 Earlier versions conflict with (among other things) the latest opencv.