Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no pytorch_jni in java.library.path windows #44363

Closed
beeqwe opened this issue Sep 9, 2020 · 5 comments
Closed

no pytorch_jni in java.library.path windows #44363

beeqwe opened this issue Sep 9, 2020 · 5 comments
Assignees
Labels
module: windows Windows support for PyTorch oncall: java triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module windows-triaged

Comments

@beeqwe
Copy link

beeqwe commented Sep 9, 2020

Hello, i'm trying to load my model using pytorch_java_only but it's return this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no pytorch_jni in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	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:11)
	at org.pytorch.Module.load(Module.java:23)
	at com.github.beeqwe.Bootstrap.main(Bootstrap.java:18)

How to reproduce the bug:

OS: Windows

public static void main(String[] args) throws IOException {
    System.setProperty("java.library.path", LIBTORCH_PATH + "lib");

    Module mod = Module.load(MODEL_PATH + "model.pt1"); //LINE 18
    Tensor data =
            Tensor.fromBlob(
                    new int[]{1, 2, 3, 4, 5, 6}, // data
                    new long[]{2, 3} // shape
            );
    IValue result = mod.forward(IValue.from(data), IValue.from(3.0));
    Tensor output = result.toTensor();

    System.out.println("shape: " + Arrays.toString(output.shape()));
    System.out.println("data: " + Arrays.toString(output.getDataAsFloatArray()));
}

pom.xml:

<dependency>
     <groupId>org.pytorch</groupId>
      <artifactId>pytorch_java_only</artifactId>
      <version>1.6.0</version>
</dependency>
<dependency>
    <groupId>com.facebook.fbjni</groupId>
    <artifactId>fbjni-java-only</artifactId>
    <version>0.0.3</version>
</dependency>
<dependency>
    <groupId>com.facebook.soloader</groupId>
    <artifactId>nativeloader</artifactId>
    <version>0.8.0</version>
</dependency>

LIBTORCH_PATH this is directory of files which downloaded from there

And i noticed one regularity, linux archive contains the libpytorch_jni.so file and macos archive contains the libpytorch_jni.dylib, but in windows archive no similar file. Same with libfbjni.so and libfbjni.dylib. Could you help me? Maybe i do something wrong.

Thanks!

cc @peterjc123 @maxluk @nbcsm @guyang3532 @gunandrose4u @smartcat2010 @mszhanyi

@mrshenli mrshenli added oncall: java module: windows Windows support for PyTorch triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Sep 9, 2020
@erip
Copy link
Contributor

erip commented Sep 10, 2020

There are no Java bindings for Windows yet. I'm currently working on this feature, and am making appropriate changes in upstream dependencies - hopefully this can be resolved soon.

@mszhanyi
Copy link
Collaborator

mszhanyi commented Sep 10, 2020

@beeqwe so far, windows binaries doesn't support java.

@mszhanyi
Copy link
Collaborator

Duplicate of #32516

@mszhanyi mszhanyi marked this as a duplicate of #32516 Sep 17, 2020
@erip
Copy link
Contributor

erip commented Oct 15, 2020

@mszhanyi I think this can be closed with the merge of #44257

@mszhanyi
Copy link
Collaborator

@erip. Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: windows Windows support for PyTorch oncall: java triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module windows-triaged
Projects
None yet
Development

No branches or pull requests

4 participants