javacpp-presets icon indicating copy to clipboard operation
javacpp-presets copied to clipboard

[PyTorch 2.2.2-1.5.11-SNAPSHOT] Exception java.lang.UnsatisfiedLinkError: no jnitorch in java.library.path on WIndows

Open haifengl opened this issue 1 year ago • 2 comments
trafficstars

The same code works fine with 2.2.1-1.5.11-SNAPSHOT.

haifengl avatar May 13 '24 03:05 haifengl

Which platform?

saudet avatar May 13 '24 04:05 saudet

It doesn't work on Windows 10. It works on Ubuntu 22.04 and macOS 13/14. It doesn't work on older macOS though (e.g. macOS 11). It is fine to drop the support of older macOS.

haifengl avatar May 13 '24 14:05 haifengl

Could you check what the Dependencies tool says is missing? https://github.com/bytedeco/javacpp-presets/wiki/Debugging-UnsatisfiedLinkError-on-Windows

saudet avatar May 15 '24 08:05 saudet

dll c10, asmjit, and libomp140 are missing on Windows 10.

haifengl avatar May 15 '24 14:05 haifengl

On macOS 11, it cannot load macosx-x86_64/libjnitorch.dylib. However, the libjnitorch.dylib file does exist.

Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /Users/xyz/.javacpp/cache/pytorch-2.2.2-1.5.11-20240502.145852-21-macosx-x86_64.jar/org/bytedeco/pytorch/macosx-x86_64/libjnitorch.dylib

haifengl avatar May 15 '24 14:05 haifengl

@haifengl @sbrunk Could you please test the builds on Windows and Mac?

saudet avatar May 15 '24 14:05 saudet

BTW, macOS 11 is no longer supported by either Apple or GitHub, so please upgrade to at least macOS 12

saudet avatar May 15 '24 14:05 saudet

It is okay to drop supporting macOS 11. Does PyTorch 2.2.2-1.5.11-SNAPSHOT support macOS on arm64 yet?

haifengl avatar May 15 '24 18:05 haifengl

I run a test on a windows 10 VM with 2.2.2 and it works, but jnitorch.dll is indeed linked with libomp140.x86_64.dll that is found in my \windows\system32. It probably came with VS or another software.

I guess we should include an OpenMP library in the jar. I'm seeing that the official libtorch archive includes the Intel version.

@saudet, what's the best way to do this ? the Pytorch CMakeList.txt doesn't use InstallRequiredSystemLibraries

HGuillemet avatar May 18 '24 11:05 HGuillemet

That's apparently a file that comes with Visual Studio, so we should add it to this preload list here: https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/presets/javacpp.java#L42

saudet avatar May 18 '24 13:05 saudet

Ok. Openmp is not used by many presets. Shouldn't we add it to the preload list of presets needing it only ?

HGuillemet avatar May 18 '24 13:05 HGuillemet

No, please don't do that

saudet avatar May 18 '24 13:05 saudet

Ok, would you like a PR for this or can you add it directly ?

HGuillemet avatar May 18 '24 13:05 HGuillemet

Yes, pull requests always welcome :) Thanks

saudet avatar May 18 '24 13:05 saudet

Thanks. It runs on Windows now. However, it doesn't produce good models on Windows though. I will create a new ticket about it.

haifengl avatar May 20 '24 03:05 haifengl