Using 1.2 version of javacpp-presets on mac os by either manually adding the jar caffe-macosx-x86_64.jarand its dependencies to the build path OR using
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>caffe</artifactId>
<version>rc3-1.2</version>
</dependency>
results in "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jnicaffe in java.library.path".
By manually extracting the native libs within the jar :
libcaffe.so.1.0.0-rc3 libjnicaffe.dylib
and then running otool -L on the dylib I get:
otool -L libjnicaffe.dylib
libjnicaffe.dylib:
libjnicaffe.dylib (compatibility version 0.0.0, current version 0.0.0)
libcaffe.so.1.0.0-rc3 (compatibility version 0.0.0, current version 0.0.0)
@rpath/libopencv_highgui.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
@rpath/libopencv_videoio.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
@rpath/libopencv_imgcodecs.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
@rpath/libopencv_imgproc.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
@rpath/libopencv_core.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
Which shows that the libcaffe.so.1.0.0-rc3 is referenced without @rpath which I'm suspecting should be there just like it was in the previous verison (master-1.1)
I haven't changed much in that regards since 1.1, but if you could create a patch for that, it would be most welcome!
First I hope someone can confirm the bug. I don't have access to another mac machine currently, and I want to make sure it isn't some configuration error on mine.
If the cause of the exception says "libcaffe.so.1.0.0-rc3: No such file or directory" or something along those lines, then yes, it's an rpath problem.
@danwexler was supposed to look into that actually. Any updates?
No update, though I still hope to return to this work shortly.
Hello,
Any update regarding this issue? I've retried to build caffe on a GPU-less Mac OSX after update 1.2.2 and got the same error:
Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/g3/nyry1nsx6lg0vjb5nkbw7jt40000gn/T/javacpp484459512188470/libjnicaffe.dylib: dlopen(/private/var/folders/g3/nyry1nsx6lg0vjb5nkbw7jt40000gn/T/javacpp484459512188470/libjnicaffe.dylib, 1): Library not loaded: libcaffe.so.1.0.0-rc3
Referenced from: /private/var/folders/g3/nyry1nsx6lg0vjb5nkbw7jt40000gn/T/javacpp484459512188470/libjnicaffe.dylib
Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)...
I'm modifying the cpp_build.sh as mentioned over here https://github.com/bytedeco/javacpp-presets/issues/219 to get this working with CPU support only.
@bisher3 As mentioned over there, it should be possible to get rid of that issue by linking with --cudart=static. This way, Caffe compiled with GPU should still run on machines without GPU, as long as CUDA is installed (and this is something we can deal with after by simply bundling all the binaries of CUDA). Could you try this out and let me know what that gives? It would help a lot!
I've just released an update that I've tested on Mac OS X and it works fine. It has version "master-1.2":
https://github.com/bytedeco/javacpp-presets/tree/master/caffe
http://search.maven.org/#search%7Cga%7C1%7Cbytedeco%20caffe
It looks like they've fixed the issue with rpath. Enjoy!
Most helpful comment
No update, though I still hope to return to this work shortly.