java-demo
java-demo copied to clipboard
Exception in thread "main" com.facebook.jni.CppException: open file failed, file path: /tmp/model-deploy.pt
Hi,
I have a model JIT-compiled in R torch that loads fine in PyTorch 1.9. However, I can't load it from Java:
Exception in thread "main" com.facebook.jni.CppException: open file failed, file path: /tmp/model-deploy.pt
Exception raised from FileAdapter at /pytorch/caffe2/serialize/file_adapter.cc:11 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0x42 (0x7f9649dafa22 in /home/key/libtorch_noncxx11/lib/libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::string const&) + 0x5b (0x7f9649dac3db in /home/key/libtorch_noncxx11/lib/libc10.so)
frame #2: caffe2::serialize::FileAdapter::FileAdapter(std::string const&) + 0x1c9 (0x7f95f2e32269 in /home/key/libtorch_noncxx11/lib/libtorch_cpu.so)
frame #3: torch::jit::load(std::string const&, c10::optional<c10::Device>, std::unordered_map<std::string, std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) + 0x30 (0x7f95f41eac60 in /home/key/libtorch_noncxx11/lib/libtorch_cpu.so)
frame #4: <unknown function> + 0x215dc (0x7f96507195dc in /home/key/libtorch_noncxx11/lib/libpytorch_jni.so)
frame #5: <unknown function> + 0x2257f (0x7f965071a57f in /home/key/libtorch_noncxx11/lib/libpytorch_jni.so)
frame #6: [0x7f9668876a30]
at org.pytorch.NativePeer.initHybrid(Native Method)
at org.pytorch.NativePeer.<init>(NativePeer.java:27)
at org.pytorch.Module.load(Module.java:28)
at org.pytorch.Module.load(Module.java:38)
at demo.App.main(App.java:11)
Would you by chance have an idea what could be the reason/ how to make progress with this?
Many thanks!!
Also tried re-building my R torch to use the pre-CXX 11 ABI as well, but still get same error.