Python easyocr 导致 python VM 崩溃(与 opencv 无关)

问题描述 投票:0回答:1

大家早上好!!!

我在

easyocr
运行
raspberry pi 4
时遇到了
ubuntu 22.04LTS
的问题。

全部使用

pip
(
pip install torch, torchvision, opencv-python, opencv-contrib-python, easyocr
) 安装。

内核崩溃:

reader = easyocr.Reader(['pt'], gpu=False)

输出是:

EasyOCR is crashing the Python 3.10 VM
Ubuntu 22.04 / Debian Bullseye (identical problem but Python 3.9)
Architecture Raspberry Pi 4 4GBytes

错误如下:

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)

由于之前运行过,没有出现此类错误,所以我尝试重新安装所有内容,但没有效果。这包括重新安装整个 ubuntu。

python segmentation-fault crash torch easyocr
1个回答
0
投票

通过改装火炬和火炬视觉解决了问题。 火炬==2.0.1 火炬视觉==0.15.2 早期版本与(除其他外)最新的 opencv 冲突。

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 torch
>>> print(torch.__version__)
2.0.1
>>> import torchvision
>>> print(torchvision.__version__)
0.15.2
>>> import easyocr
>>> reader = easyocr.Reader(['pt'])
Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.
>>> quit()
© www.soinside.com 2019 - 2024. All rights reserved.