google-coral / edgetpu

Coral issue tracker (and legacy Edge TPU API source)
https://coral.ai
Apache License 2.0
422 stars 124 forks source link

segmentation fault #660

Closed UcefMountacer closed 1 year ago

UcefMountacer commented 1 year ago

I'm a raspberry pi user. I followed the guide on this page : https://coral.ai/docs/accelerator/get-started/#next-steps


cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

and with the demo model they provided, I get the error:

user@raspberrypi:~/coral/pycoral $ python3 examples/classify_image.py --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels test_data/inat_bird_labels.txt --input test_data/parrot.jpg Segmentation fault

I traced the issue:

 --- modulename: interpreter, funcname: __init__
interpreter.py(101):         self.message = ''
interpreter.py(107):     error_capturer_cb = ctypes.CFUNCTYPE(None, ctypes.c_char_p)(capture.report)
 --- modulename: __init__, funcname: CFUNCTYPE
__init__.py(92):     flags = _FUNCFLAG_CDECL
__init__.py(93):     if kw.pop("use_errno", False):
__init__.py(95):     if kw.pop("use_last_error", False):
__init__.py(97):     if kw:
__init__.py(99):     try:
__init__.py(100):         return _c_functype_cache[(restype, argtypes, flags)]
interpreter.py(109):     self._delegate_ptr = self._library.tflite_plugin_create_delegate(
interpreter.py(110):         options_keys, options_values, len(options), error_capturer_cb)
interpreter.py(109):     self._delegate_ptr = self._library.tflite_plugin_create_delegate(
interpreter.py(111):     if self._delegate_ptr is None:
interpreter.py(178):   return delegate
edgetpu.py(88):   if isinstance(model_path_or_content, bytes):
edgetpu.py(92):     return tflite.Interpreter(
edgetpu.py(93):         model_path=model_path_or_content, experimental_delegates=delegates)
edgetpu.py(92):     return tflite.Interpreter(
 --- modulename: interpreter, funcname: __init__
interpreter.py(434):     if not hasattr(self, '_custom_op_registerers'):
interpreter.py(435):       self._custom_op_registerers = []
interpreter.py(437):     actual_resolver_type = experimental_op_resolver_type
interpreter.py(438):     if experimental_preserve_all_tensors and (
interpreter.py(442):     op_resolver_id = _get_op_resolver_id(actual_resolver_type)
 --- modulename: interpreter, funcname: _get_op_resolver_id
interpreter.py(347):       OpResolverType.AUTO: 1,
interpreter.py(348):       OpResolverType.BUILTIN: 1,
interpreter.py(349):       OpResolverType.BUILTIN_REF: 2,
interpreter.py(350):       OpResolverType.BUILTIN_WITHOUT_DEFAULT_DELEGATES: 3
interpreter.py(345):   return {
 --- modulename: enum, funcname: __hash__
enum.py(746):         return hash(self._name_)
 --- modulename: enum, funcname: __hash__
enum.py(746):         return hash(self._name_)
 --- modulename: enum, funcname: __hash__
enum.py(746):         return hash(self._name_)
 --- modulename: enum, funcname: __hash__
enum.py(746):         return hash(self._name_)
interpreter.py(351):   }.get(op_resolver_type, None)
interpreter.py(345):   return {
 --- modulename: enum, funcname: __hash__
enum.py(746):         return hash(self._name_)
interpreter.py(443):     if op_resolver_id is None:
interpreter.py(447):     if model_path and not model_content:
interpreter.py(448):       custom_op_registerers_by_name = [
interpreter.py(449):           x for x in self._custom_op_registerers if isinstance(x, str)
interpreter.py(448):       custom_op_registerers_by_name = [
 --- modulename: interpreter, funcname: <listcomp>
interpreter.py(448):       custom_op_registerers_by_name = [
interpreter.py(451):       custom_op_registerers_by_func = [
interpreter.py(452):           x for x in self._custom_op_registerers if not isinstance(x, str)
interpreter.py(451):       custom_op_registerers_by_func = [
 --- modulename: interpreter, funcname: <listcomp>
interpreter.py(451):       custom_op_registerers_by_func = [
interpreter.py(455):           _interpreter_wrapper.CreateWrapperFromFile(
interpreter.py(456):               model_path, op_resolver_id, custom_op_registerers_by_name,
interpreter.py(457):               custom_op_registerers_by_func, experimental_preserve_all_tensors))
interpreter.py(455):           _interpreter_wrapper.CreateWrapperFromFile(
interpreter.py(454):       self._interpreter = (
interpreter.py(458):       if not self._interpreter:
interpreter.py(480):     if num_threads is not None:
interpreter.py(491):     self._delegates = []
interpreter.py(492):     if experimental_delegates:
interpreter.py(493):       self._delegates = experimental_delegates
interpreter.py(494):       for delegate in self._delegates:
interpreter.py(495):         self._interpreter.ModifyGraphWithDelegate(
interpreter.py(496):             delegate._get_native_delegate_pointer())  # pylint: disable=protected-access
 --- modulename: interpreter, funcname: _get_native_delegate_pointer
interpreter.py(130):     return self._delegate_ptr
interpreter.py(495):         self._interpreter.ModifyGraphWithDelegate(
Segmentation fault

Thanks for any help !!

UcefMountacer commented 1 year ago

This is a raspbian Bullseye issue. It works with Buster.

hjonnala commented 1 year ago

Its working for me on Bullseye. Can you try uninstall Coral packages and install it again. Thanks!

UcefMountacer commented 1 year ago

Okey. I will do it once I have an opportunity to access the Pi.

Can you tell me some details about your setup?

Thanks

hjonnala commented 1 year ago

Sure Thing!!


pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.15.32-v7l+ #1538 SMP Thu Mar 31 19:39:41 BST 2022 armv7l GNU/Linux

pi@raspberrypi:~ $ python3
Python 3.9.2 (default, Mar 12 2021, 04:06:34) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tflite_runtime as tflite
>>> from pycoral.utils.edgetpu import get_runtime_version
>>> get_runtime_version()
'BuildLabel(COMPILER=6.3.0 20170516,DATE=redacted,TIME=redacted), RuntimeVersion(14)'
>>> tflite.__version__
'2.5.0.post1'
>>> import pycoral
>>> pycoral.__version__
'2.0.0'
>>> quit()

pi@raspberrypi:~/pycoral $ python3 examples/classify_image.py --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels test_data/inat_bird_labels.txt --input test_data/parrot.jpg
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
18.0ms
4.9ms
5.0ms
4.9ms
5.1ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.75781
pi@raspberrypi:~/pycoral $ 
google-coral-bot[bot] commented 1 year ago

Are you satisfied with the resolution of your issue? Yes No

hfsilberg commented 1 year ago

had this exact issue of running the coral example on a raspberry pi

turned out to be an incompatible tflite version

fixed with: pip uninstall tflite-runtime sudo apt-get install python3-tflite-runtime

s3tr commented 7 months ago

no solution in bullseye raspberry pi 3