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

java.lang.UnsatisfiedLinkError: no pytorch_jni in java.library.path #28

@dzlab

Description

@dzlab

I am trying to build this demo project on mac, I installed libtorch with brew

$ brew install libtorch

This installed libtorch 1.10.0 in /usr/local/Cellar/libtorch/1.10.0
there was no build-version file so I created one with the version like this

cat > /usr/local/Cellar/libtorch/1.10.0/build-version << EOF
1.10.0
EOF

Then had to modify build.gradle#L8 to match my installed version

- def LIBTORCH_VERSION = USE_NIGHTLY ? "1.10.0-SNAPSHOT" : "1.9.0";
+ def LIBTORCH_VERSION = USE_NIGHTLY ? "1.10.0-SNAPSHOT" : "1.10.0";

The I export the libtorch path

$ export LIBTORCH_HOME=/usr/local/Cellar/libtorch/1.10.0

Now when I try to build the demo, it fails the pytorch_jni file

$ ./gradlew run   

> Task :run FAILED
Exception in thread "main" java.lang.UnsatisfiedLinkError: no pytorch_jni in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
        at java.lang.Runtime.loadLibrary0(Runtime.java:871)
        at java.lang.System.loadLibrary(System.java:1122)
        at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:22)
        at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:43)
        at org.pytorch.NativePeer.<clinit>(NativePeer.java:10)
        at org.pytorch.Module.load(Module.java:28)
        at org.pytorch.Module.load(Module.java:38)
        at demo.App.main(App.java:11)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

@dreiss any ideas??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions