Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

macOS File Permission Issue at Runtime #8

Closed
suyashcjoshi opened this issue Apr 12, 2020 · 1 comment
Closed

macOS File Permission Issue at Runtime #8

suyashcjoshi opened this issue Apr 12, 2020 · 1 comment

Comments

@suyashcjoshi
Copy link

suyashcjoshi commented Apr 12, 2020

While following the directions to compile and run the gradle demo app, I ran into strage macOS Catalina issue. This happens after executing the following command.
pop up dialog.

.gradle run command

Please see the attached screenshots of the OS
Screen Shot 2020-04-12 at 1 01 18 AM
Screen Shot 2020-04-12 at 1 00 31 AM

StackTrace of the Build Fail exception:

~/Code/Java/LibTorch-PyTorch/java-demo-master $ ./gradlew run

Task :run FAILED
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/sj/Code/Java/LibTorch-PyTorch/libtorch/lib/libpytorch_jni.dylib: dlopen(/Users/sj/Code/Java/LibTorch-PyTorch/libtorch/lib/libpytorch_jni.dylib, 1): Library not loaded: @rpath/libtorch_cpu.dylib
Referenced from: /Users/sj/Code/Java/LibTorch-PyTorch/libtorch/lib/libpytorch_jni.dylib
Reason: no suitable image found. Did find:
/Users/sj/Code/Java/LibTorch-PyTorch/libtorch/lib/libtorch_cpu.dylib: code signature in (/Users/sj/Code/Java/LibTorch-PyTorch/libtorch/lib/libtorch_cpu.dylib) not valid for use in process using Library Validation: library load disallowed by system policy
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2649)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
at java.base/java.lang.System.loadLibrary(System.java:1870)
at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:22)
at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:43)
at org.pytorch.NativePeer.(NativePeer.java:11)
at org.pytorch.Module.load(Module.java:23)
at demo.App.main(App.java:12)

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':run'.

Process 'command '/Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

@suyashcjoshi
Copy link
Author

Here is the fix that I found and submitting a documentation update PR for the same so it can help other macOS users.

Run the following commands after the warning popup occurs so as to delete the macOS quarantine flag from all the files inside of /path/to/libtorch/lib folder

xattr -r -d com.apple.quarantine /path/to/libtorch/lib
./gradlew run

suyashcjoshi pushed a commit to suyashcjoshi/java-demo that referenced this issue Apr 12, 2020
Updated the readme file to improve documentation specially for macOS users. Clarified steps to resolve this issue pytorch#8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant