schwittlick / ofxDarknet

darknet neural network addon for openFrameworks
MIT License
496 stars 89 forks source link

dyld: Library not loaded: @rpath/libdarknetOSX.dylib #3

Closed genekogan closed 7 years ago

genekogan commented 7 years ago

the OSX dynlib for darknet is not found at runtime unless it is placed right next to the app. as a temp fix, put a copy of libdarknetOSX.dylib beside the app itself.

to fix this, we need to fix the linker location for the dylib.

peterkolski commented 7 years ago

Error message:

dyld: Library not loaded: @rpath/libdarknetOSX.dylib
...
 Reason: image not found
peterkolski commented 7 years ago

We can fix this by setting in xCode: Build Settings / Runpath Search Paths {blabla}.. libs/darknet/lib/osx/ Let's see, if this can be set via the Project Generator

peterkolski commented 7 years ago

If I add into the addon_config.mk ADDON_LDFLAGS = -rpath /Users/sonneundasche/programming/of/addons/ofxDarknet/libs/darknet/lib/osx It works, but that's an absolute path

schwittlick commented 7 years ago

what about this:

ADDON_LDFLAGS = -rpath $(OF_ROOT)/addons/ofxDarknet/libs/darknet/lib/osx
genekogan commented 7 years ago

this appears to work. a7eb27704aeb09c0dc691f8da0f5f426f0199476

ADDON_LDFLAGS = -rpath ../../../../addons/ofxDarknet/libs/darknet/lib/osx
jakeelwes commented 7 years ago

Heya, I'm still getting:

dyld: Library not loaded: @rpath/libcudart.8.0.dylib
  Referenced from: /.../OpenFrameworks/of_v0.9.8_osx_release/addons/ofxDarknet/example-yolo2/bin/libdarknetOSX.dylib
  Reason: image not found
(lldb) 

(Thread 1: 0_abort_with_payload on run)

libdarknetOSX.dylib is in the project bin, and I'm up to date with your latest commit (i.e the ADDON_LDFLAGS is correct) anything else I've missed?

Thanks guys, awesome job putting this together

Also do I need to specify using CPU and not cuda/GPU in addon_config (tried commenting out the cuda paths but then get other errors) / Will it work on CPU?

genekogan commented 7 years ago

do you have CUDA installed? or in a different path? right now it's searching for cuda in /usr/local/cuda/, so you should have a file libcudart.8.0.dylib inside /usr/local/cuda/lib/. if you have cuda in a different location, you'd need to change the CUDA search path in the addon_config.mk file or in the xcode project file. it's also assuming CUDA 8.0 -- if you have an older version, we'd need to link against that for it to work. potentially it could work with just using symlinks to your version of cuda.

jakeelwes commented 7 years ago

I have CUDA 7 installed but not sure it ever worked as I don't have a nvidia GPU on my macbook (can try install CUDA 8 but I thought you needed a GPU). Bit confused though as it says darknet supports CPU and GPU computation but is written in Cuda?

If its only for GPU then no worries, I think its a dead end, I'll just keep playing on my AWS :)

genekogan commented 7 years ago

are you sure you don't have NVIDIA? check graphics in About this mac. if you have CUDA 7, you should be able to switch to CUDA 8 without much difficulty. it's possible that it may work without problems with CUDA 7, we haven't tested that. one quick way to check is to make symlinks for all the needed files, so e.g. libcudart.8.0.dylib links to libcudart.7.0.dylib or whatever you have... its a hack but it could work. otherwise try cuda 8.

the repo is hard-coded to just use GPU at the moment. we might make it an option, but everything becomes at least 10x slower in CPU mode, which defeats the purpose of bringing it into OF to begin with.

jakeelwes commented 7 years ago

Yeah no NVIDIA. I have the Retina 13-inch Late 2013 with an integrated GPU - Intel Iris 1536 MB - only the larger ones have the dedicated Nvidia GPU (hence having to use AWS for all GPU stuff - bit of a bore), thanks though Gene. I might try playing with Redmon's DarkNet in CPU mode though