Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Delegate' object has no attribute '_library' #22

Open
fablau opened this issue Jun 8, 2021 · 24 comments
Open

AttributeError: 'Delegate' object has no attribute '_library' #22

fablau opened this issue Jun 8, 2021 · 24 comments
Assignees
Labels
Hardware:USB Accelerator Coral USB Accelerator issues subtype:macOS macOS Build/installation issues type:feature Feature requests

Comments

@fablau
Copy link

fablau commented Jun 8, 2021

Hello, Just installed it on MacOS 11.5 and when I run the first example "python3 bodypix.py" I get this error:

Model: models/bodypix_mobilenet_v1_075_640_480_16_quant_edgetpu_decoder.tflite Traceback (most recent call last): File "bodypix.py", line 180, in <module> main() File "bodypix.py", line 161, in main engine = PoseEngine(model) File "/Users/fabrizio/Desktop/work/MagneticChessResearch/machine learning/Coral/edgetpu_runtime/coral/pycoral/TEST1/project-bodypix/pose_engine.py", line 142, in __init__ edgetpu_delegate = load_delegate(EDGETPU_SHARED_LIB) File "/Users/fabrizio/.local/share/virtualenvs/Coral-u4jlFv0K/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 152, in load_delegate delegate = Delegate(library, options) File "/Users/fabrizio/.local/share/virtualenvs/Coral-u4jlFv0K/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 81, in __init__ self._library = ctypes.pydll.LoadLibrary(library) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 443, in LoadLibrary return self._dlltype(name) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode) OSError: dlopen(libedgetpu.so.1, 6): image not found Exception ignored in: <function Delegate.__del__ at 0x125e94ee0> Traceback (most recent call last): File "/Users/fabrizio/.local/share/virtualenvs/Coral-u4jlFv0K/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 116, in __del__ if self._library is not None: AttributeError: 'Delegate' object has no attribute '_library'

Any ideas?

@manoj7410
Copy link

@fablau Were you able to fix this ?

@fablau
Copy link
Author

fablau commented Jul 12, 2021

Unfortunately not, the problem is still there. Any thoughts?

@hjonnala
Copy link

Can you try to install the edgeptu runtime folllowing these instructions: https://coral.ai/docs/accelerator/get-started/#runtime-on-mac

@fablau
Copy link
Author

fablau commented Jul 12, 2021

Yes, that's what I have done and I am able to run the tests as well as the following examples without issues:

https://github.com/google-coral/examples-camera

@hjonnala
Copy link

cool, can we close this issue?

@fablau
Copy link
Author

fablau commented Jul 12, 2021

Why? I haven't been able to make this run. I still get the error I mentioned in my first post above!

@hjonnala
Copy link

sorry, I thought you are able to run the tests without issues.

@fablau
Copy link
Author

fablau commented Jul 12, 2021

I am able to run the tests here:
https://github.com/google-coral/examples-camera

But not this specific "project-bodypix" we are discussing about here ;)

@hjonnala
Copy link

can you please confirm you have downloaded tflite runtime form this link https://github.com/google-coral/pycoral/releases/download/v1.0.1/tflite_runtime-2.5.0-cp38-cp38-macosx_10_15_x86_64.whl as you are using python3.8 and Mac

releases: https://github.com/google-coral/pycoral/releases

@fablau
Copy link
Author

fablau commented Jul 12, 2021

Yes, I can confirm that.

@hjonnala
Copy link

Hmm..please share the output of below command:
v4l2-ctl --list-devices

@fablau
Copy link
Author

fablau commented Jul 12, 2021

With that, I get a "v4l2-ctl: command not found" error.

@fablau
Copy link
Author

fablau commented Jul 13, 2021

Thank you for your suggestion, but I have that library inside the same directory of the "bodypix.py" script:

posenet_lib/x86_64/posenet_decoder.so

It should work, right?

@hjonnala
Copy link

hjonnala commented Jul 28, 2021

Hi @fablau unfortunately Project-bodypix does not work on MacOS. It would work on linux machines and coral dev board.

@hjonnala hjonnala added Hardware:USB Accelerator Coral USB Accelerator issues stat:awaiting Coral team Status - Awaiting response from Coral team subtype:macOS macOS Build/installation issues type:feature Feature requests labels Aug 4, 2021
@aldenprudent
Copy link

Are there plans to support macOS? I'd love to see this running without having to drop into a VM

@hjonnala
Copy link

hjonnala commented Oct 4, 2021

@aldenprudent Please try posenet_decoder.dylib by placing here

  • and changing this line to EDGETPU_SHARED_LIB = 'libedgetpu.1.dylib'
  • and changing this line to 'posenet_lib', os.uname().machine, 'posenet_decoder.dylib')

@aldenprudent
Copy link

aldenprudent commented Oct 11, 2021

@hjonnala thank you for that! How did you obtain the dylib? I wanted to compile posenet from source but the requirements were more than I had time for a few days back.

I'm still unable to get everything to work but it's failing further along trying to load 'v4l2src' in the gstreamer pipeline. I'll report back if I can get everything resolved.

@hjonnala
Copy link

@aldenprudent here are the steps to build posent lib for macOS.

git clone --recurse-submodules https://github.com/google-coral/libcoral
cd libcoral

Add the below lines to pose estmation build at the end of file.

cc_binary(
    name = "macos_posenet_decoder.so",
    srcs = ["posenet_decoder_tflite_plugin.cc"],
    linkopts = [
          "-Wl,-install_name,@rpath/posenet_decoder.dylib",
    ],
    linkshared = 1,
    linkstatic = 1,
    deps = [
        ":posenet_decoder_op",
        "@org_tensorflow//tensorflow/lite:kernel_api",
        "@org_tensorflow//tensorflow/lite:util",
    ],
)

Run the below commands

bazel clean
bazel build coral/pose_estimation:macos_posenet_decoder.so

after successful build please find the macos_posenet_decoder.so @bazel-out/darwin-fastbuild/bin/coral/pose_estimation/macos_posenet_decoder.so

Current gstreamer pipeline does not work with macOS. you can test macos_posenet_decoder.so file by runing simple_pose.py and making similar changes to pose_engine.py

@fablau
Copy link
Author

fablau commented Oct 11, 2021

Thank you so much! I'll try and let you know if it works for me. Appreciated!

@aldenprudent
Copy link

Sorry for the late reply on this. I'm unable to get the gstreamer bits working but I am able to get a basic image response now. Here's the diff.

@fablau
Copy link
Author

fablau commented Oct 28, 2021

@aldenprudent here are the steps to build posent lib for macOS.

git clone --recurse-submodules https://github.com/google-coral/libcoral
cd libcoral

Add the below lines to pose estmation build at the end of file.

cc_binary(
    name = "macos_posenet_decoder.so",
    srcs = ["posenet_decoder_tflite_plugin.cc"],
    linkopts = [
          "-Wl,-install_name,@rpath/posenet_decoder.dylib",
    ],
    linkshared = 1,
    linkstatic = 1,
    deps = [
        ":posenet_decoder_op",
        "@org_tensorflow//tensorflow/lite:kernel_api",
        "@org_tensorflow//tensorflow/lite:util",
    ],
)

Run the below commands

bazel clean
bazel build coral/pose_estimation:macos_posenet_decoder.so

after successful build please find the macos_posenet_decoder.so @bazel-out/darwin-fastbuild/bin/coral/pose_estimation/macos_posenet_decoder.so

Current gstreamer pipeline does not work with macOS. you can test macos_posenet_decoder.so file by runing simple_pose.py and making similar changes to pose_engine.py

Ok, I tried what you suggested, but now I get a different error, it looks like a BUILD file is missing:

ERROR: Error fetching repository: ~/Coral/edgetpu_runtime/coral/pycoral/WORKSPACE:31:21: In new_local_repository rule //external:libedgetpu the 'build_file' attribute does not specify an existing file (~/Coral/edgetpu_runtime/coral/pycoral/libedgetpu/BUILD does not exist)

@hjonnala hjonnala removed the stat:awaiting Coral team Status - Awaiting response from Coral team label May 13, 2022
@zain-altaf
Copy link

zain-altaf commented Oct 20, 2022

hi @hjonnala I seem to be encountering a similar situation. I got the WSL with Ubuntu on my Windows since the repo only works on Linux based systems. So I'm using Ubuntu on Windows terminal to do most of the work now. I came across the tflite_runtime issue as well and was confused what you meant by downloading the pycoral version. I have python 3.8 and linux so I just downloaded pycoral-2.0.0-cp38-cp38-linux_x86_64.whl. I hope that's the right one, and I dragged that into the bodypix project folder. I tried the v4l2-ctl --list-devices command and got the following error: Cannot open device /dev/video0, exiting. I was confused about what exactly I should do from here.

If you see the code at https://github.com/google-coral/project-posenet/blob/ugrade-to-frogfish/pose_engine.py#L79-L83 , it requires posenet_decoder.so. Make sure that the library is at the correct path at https://github.com/google-coral/project-posenet/blob/ugrade-to-frogfish/pose_engine.py#L32

Library is available at https://github.com/google-coral/project-bodypix/tree/master/posenet_lib/x86_64

Also relating to this comment you made earlier, I was really confused what exactly I'm supposed to be doing here to get the repo working. Please let me know how I might be able to fix the above error and also what exactly I need to do to this ^^ post you made earlier. Thanks!

EDIT: I have a logitech camera attached to my device now, not sure if that impacts the cannot open device issue

EDIT Pt 2: I think I'm almost there in terms of getting all the dependencies working and whatnot but I'm still having a few issues. Following ___ they had steps to follow in order to install PyCoral API. sudo apt-get install python3-pycoral wasn't working for me as it said:

Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package python3-pycoral

So I tried the alternate terminal command python3 -m pip install --extra-index-url https://google-coral.github.io/py-repo/ pycoral~=2.0 instead. But they mention on the website: "If you download a wheel from the following table to install manually with pip install, you must also install the corresponding the tflite_runtime wheel." So I decided to do pip install https://github.com/google-coral/pycoral/releases/download/v2.0.0/pycoral-2.0.0-cp38-cp38-linux_x86_64.whl. When I ran python bodypix.py I got this new error I haven't gotten before:

Traceback (most recent call last): File "bodypix.py", line 29, in <module> from pose_engine import PoseEngine, EDGES, BODYPIX_PARTS File "/mnt/c/Users/zalta/Desktop/project-bodypix/project-bodypix/pose_engine.py", line 28, in <module> from pycoral.utils.edgetpu import run_inference File "/home/zainaltaf/.local/lib/python3.8/site-packages/pycoral/utils/edgetpu.py", line 24, in <module> from pycoral.pybind._pywrap_coral import GetRuntimeVersion as get_runtime_version ImportError: libedgetpu.so.1: cannot open shared object file: No such file or directory

I'm not sure how to proceed please let me know if you can help me out here. Thanks!

@hjonnala
Copy link

@zain-altaf seems to be you haven't installed the edgetpu runtime. Please follow these instructions and try the basic demo first before trying any other repositories. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hardware:USB Accelerator Coral USB Accelerator issues subtype:macOS macOS Build/installation issues type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

5 participants