Git Product home page Git Product logo

Comments (2)

zulufoxtrot avatar zulufoxtrot commented on August 28, 2024 2

Found an explanation:
https://stackoverflow.com/questions/19776571/error-dlopen-library-not-loaded-reason-image-not-found

I'm not sure I understand the issue at hand, but I investigated and found a workaround:

First let's see where what pydarknet.cpython-37m-darwin.so is looking for:

otool -L /usr/local/lib/python3.7/site-packages/pydarknet.cpython-37m-darwin.so
/usr/local/lib/python3.7/site-packages/pydarknet.cpython-37m-darwin.so:
libdarknet.so (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)

It looks like libdarknet.so is referenced with a relative path.
Its absolute path is /usr/local/lib/python3.7/site-packages/__libdarknet/libdarknet.so

A workaround is to copy libdarknet.so to the current working directory.

But then, another error arises:

Traceback (most recent call last):
File "/Users/zulu/docs/projets/dev/python/yolo-computer-vision/YOLO3-4-Py/video_demo.py", line 3, in
from pydarknet import Detector, Image
ImportError: dlopen(/usr/local/lib/python3.7/site-packages/pydarknet.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libcudart.9.2.dylib
Referenced from: /Users/zulu/docs/projets/dev/python/yolo-computer-vision/YOLO3-4-Py/libdarknet.so
Reason: image not found

Let's run otool again:

otool -L libdarknet.so
libdarknet.so:
libdarknet.so (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
/usr/local/opt/opencv/lib/libopencv_stitching.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_superres.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_videostab.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_aruco.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_bgsegm.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_bioinspired.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_ccalib.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_dnn_objdetect.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_dpm.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_face.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_photo.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_fuzzy.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_hfs.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_img_hash.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_line_descriptor.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_optflow.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_reg.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_rgbd.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_saliency.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_stereo.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_structured_light.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_phase_unwrapping.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_surface_matching.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_tracking.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_datasets.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_dnn.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_plot.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_xfeatures2d.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_shape.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_video.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_ml.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_ximgproc.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_calib3d.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_features2d.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_highgui.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_videoio.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_flann.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_xobjdetect.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_imgcodecs.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_objdetect.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_xphoto.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_imgproc.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/opt/opencv/lib/libopencv_core.3.4.dylib (compatibility version 3.4.0, current version 3.4.2)
/usr/local/cuda/lib/libcuda.dylib (compatibility version 1.1.0, current version 9.2.64)
@rpath/libcudart.9.2.dylib (compatibility version 0.0.0, current version 9.2.148)
@rpath/libcublas.9.2.dylib (compatibility version 0.0.0, current version 9.2.148)
@rpath/libcurand.9.2.dylib (compatibility version 0.0.0, current version 9.2.148)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)

So this is the same issue as before, except this time the paths are absolute.

I don't know how @rpath works, but on my system the 3 dylibs are in Developer/NVIDIA/CUDA-9.2/lib/.

No big deal, just use install_name_tool to change the paths:

install_name_tool -change @rpath/libcudart.9.2.dylib /Developer/NVIDIA/CUDA-9.2/lib/libcudart.9.2.dylib libdarknet.so
install_name_tool -change @rpath/libcublas.9.2.dylib /Developer/NVIDIA/CUDA-9.2/lib/libcublas.9.2.dylib libdarknet.so
install_name_tool -change @rpath/libcurand.9.2.dylib /Developer/NVIDIA/CUDA-9.2/lib/libcurand.9.2.dylib libdarknet.so

After doing this, the python script runs fine!

I think something has to be changed in the install script to fix this.

from yolo3-4-py.

madhawav avatar madhawav commented on August 28, 2024

Hi @zulufoxtrot, Unfortunately, yolo34py do not officially support MacOS. I believe that is why API failed to link with libdarknet.so automatically as intended.

Anyhow, I am glad you managed to find a solution. Would you be able to share the changes you made as a pull request? Then we can maintain a separate branch for Mac OS. (Unfortunately, I will not be able to contribute to the MacOS branch since I do not have a Mac)
Cheers!

from yolo3-4-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.