google-coral / edgetpu

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

ImportError: dlopen #736

Closed titocapovilla closed 1 year ago

titocapovilla commented 1 year ago

Description

Hi, new to coral, I was installing it on my macosx.

After following this procedure https://coral.ai/docs/accelerator/get-started/#3-run-a-model-on-the-edge-tpu I got stuck at section 3

I'm using command:

python3.9 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

(Calling 3.9 as python3 calls 3.11 and does not find pycoral)

I get the log below

Traceback (most recent call last):
  File "/Users/titocapovilla/Documents/Code/coral/pycoral/examples/classify_image.py", line 40, in <module>
    from pycoral.utils.edgetpu import make_interpreter
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/utils/edgetpu.py", line 24, in <module>
    from pycoral.pybind._pywrap_coral import GetRuntimeVersion as get_runtime_version
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/_pywrap_coral.cpython-39-darwin.so, 0x0002): Library not loaded: '@rpath/libedgetpu.1.dylib'
  Referenced from: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/_pywrap_coral.cpython-39-darwin.so'
  Reason: tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/libedgetpu.1.dylib' (no such file), '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/libedgetpu.1.dylib' (no such file), '/usr/lib/libedgetpu.1.dylib' (no such file)

Not sure what's the issue I'm facing

Click to expand! ### Issue Type Build/Install ### Operating System Mac OS ### Coral Device USB Accelerator ### Other Devices _No response_ ### Programming Language _No response_ ### Relevant Log Output ```shell Traceback (most recent call last): File "/Users/titocapovilla/Documents/Code/coral/pycoral/examples/classify_image.py", line 40, in from pycoral.utils.edgetpu import make_interpreter File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/utils/edgetpu.py", line 24, in from pycoral.pybind._pywrap_coral import GetRuntimeVersion as get_runtime_version ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/_pywrap_coral.cpython-39-darwin.so, 0x0002): Library not loaded: '@rpath/libedgetpu.1.dylib' Referenced from: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/_pywrap_coral.cpython-39-darwin.so' Reason: tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/libedgetpu.1.dylib' (no such file), '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/libedgetpu.1.dylib' (no such file), '/usr/lib/libedgetpu.1.dylib' (no such file) ```
hjonnala commented 1 year ago

Hi @titocapovilla have you installed the edgetpu runtime on mac?

titocapovilla commented 1 year ago

Hi @hjonnala . Yes, I have followed the prodedure and installed edgetpu runtime in folder edgetpu_runtime as suggested by the guide.

hjonnala commented 1 year ago

can you please uninstall and installi it again and share the instalation logs.

cd edgetpu_runtime

sudo bash uninstall.sh
titocapovilla commented 1 year ago

@hjonnala Here's the logs after uninstalling and reinstalling

Warning: If you're using the Coral USB Accelerator, it may heat up during operation, depending
on the computation workloads and operating frequency. Touching the metal part of the USB
Accelerator after it has been operating for an extended period of time may lead to discomfort
and/or skin burns. As such, if you enable the Edge TPU runtime using the maximum operating
frequency, the USB Accelerator should be operated at an ambient temperature of 25°C or less.
Alternatively, if you enable the Edge TPU runtime using the reduced operating frequency, then
the device is intended to safely operate at an ambient temperature of 35°C or less.

Google does not accept any responsibility for any loss or damage if the device
is operated outside of the recommended ambient temperature range.

Note: This question affects only USB-based Coral devices, and is irrelevant for PCIe devices.
................................................................................
Would you like to enable the maximum operating frequency for your Coral USB device? Y/N
y
Using the maximum operating frequency for Coral USB devices.
Warning: port definitions are more than two weeks old, consider updating them by running 'port selfupdate'.
--->  Cleaning libusb
--->  Scanning binaries for linking errors
--->  No broken files found.                             
--->  No broken ports found.
Installing Edge TPU runtime library [/usr/local/lib]...
Generating symlink [/usr/local/lib/libedgetpu.1.dylib]...
hjonnala commented 1 year ago

Please copy the .dylib file from /usr/local/lib to /usr/lib and try the demo.

sudo cp /usr/local/lib/libedgetpu.1.dylib /usr/lib/libedgetpu.1.dylib
sudo cp /usr/local/lib/libedgetpu.1.0.dylib /usr/lib/libedgetpu.1.0.dylib
titocapovilla commented 1 year ago

@hjonnala Getting this error:

cp: /usr/lib/libedgetpu.1.dylib: Read-only file system
cp: /usr/lib/libedgetpu.1.0.dylib: Read-only file system
hjonnala commented 1 year ago
Reason: tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/libedgetpu.1.dylib' (no such file), '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/libedgetpu.1.dylib' (no such file), '/usr/lib/libedgetpu.1.dylib' (no such file)

Please try copy .dylib file to any of the folders above.

sudo cp /usr/local/lib/libedgetpu.1.dylib /usr/lib
sudo cp /usr/local/lib/libedgetpu.1.0.dylib /usr/lib
titocapovilla commented 1 year ago

@hjonnala I'm unable to copy any file into /usr/lib (I've tried doing it manually too). I have disabled csrutil but it didn't change the output.

hjonnala commented 1 year ago

Please try copying to /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/

titocapovilla commented 1 year ago

@hjonnala Success! Thanks a lot for your time! if you have a moment can you explain very briefly what was the issue? Cheers.

Ouput log:

python3.9 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

/Users/titocapovilla/Documents/Code/coral/pycoral/examples/classify_image.py:79: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use LANCZOS or Resampling.LANCZOS instead.
  image = Image.open(args.input).convert('RGB').resize(size, Image.ANTIALIAS)
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
14.5ms
3.8ms
3.5ms
3.2ms
3.2ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.75781
hjonnala commented 1 year ago

Reason: tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/libedgetpu.1.dylib' (no such file), '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycoral/pybind/libedgetpu.1.dylib' (no such file), '/usr/lib/libedgetpu.1.dylib' (no such file)

The script was not able find .dylib file. Usually, they would be in /usr/lib folder but on you system they are in /usr/local/lib folder.

google-coral-bot[bot] commented 1 year ago

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