question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Including LibTorchvision on Android

See original GitHub issue

Area Select

react-native-pytorch-core (core package)

Description

Hello, thanks for your contributions.

I encountered a error on react native android to loading custom ptl model. I think this error can solve if i can include Libtorchvision from relavated issue on this: https://github.com/facebookresearch/playtorch/issues/64

How can i include it in my android application?

Please provide me any leads. Thank you.


Error: {"message": "Following ops cannot be found. Please check if the operator library is included in the build. If built with selected ops, check if these ops are in the list. If you are a Meta employee, please see fburl.com/missing_ops for a fix. Or post it in https://discuss.pytorch.org/torchvision::nms () Exception raised from initialize_operators at /data/users/atalman/pytorch/torch/csrc/jit/mobile/function.cpp:89 (most recent call first): (no backtrace available)"}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
raedlecommented, Aug 4, 2022

Hi @nh9k, that’s correct. The nms (non-maximum suppression) op is part of the Torchvision ops. The react-native-pytorch-core doesn’t include the Torchvision ops, but they can be added to a project, if needed.

I created a repo for the D2Go model, which also requires Torchvision ops to run inference. I created a single commit for the changes that add Torchvision ops to Android and iOS. Have a look at this commit in the raedle/D2GoExample repo!

Note: for iOS it uses the LibTorchvision-DONOTUSE CocoaPod because the Torchvision ops 0.13.0 that are compatible with PyTorch 1.12 have not been released officially yet. They are coming soon, and in the meantime you can use the LibTorchvision-DONOTUSE, which are functionally equivalent to the upcoming release!

Hope that helps, and please report back if you are successful! Any feedback to the PlayTorch is helpful for us to learn 😃

Thank you!

1reaction
raedlecommented, Oct 19, 2022

@nh9k, from the logcat logs it looks like that the shared object libraries aren’t packaged correctly.

But generally, there are two parts that are important to add torchvision_ops to your app. See how this is done in the PlayTorch app:

  1. Add the torchvision_ops to the app’s build.gradle (make sure the versions for torchvision_ops and pytorch_jni_lite are compatible)
  2. Load the torchvision_ops shared object library after loading the pytorch_jni_lite shared object library (see MainApplication.java)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Android - PyTorch
pytorch:pytorch_android is the main dependency with PyTorch Android API, including libtorch native library for all 4 android abis (armeabi-v7a, arm64-v8a, x86, ...
Read more >
Support the Android NDK with libtorch · Issue #14258 - GitHub
For example, in my case, I can't run libtorch even a rooted Android phone because the architecture (aarch64) still has differences in ...
Read more >
Full C++ LibTorch API on Moblie [Android] - Stack Overflow
I'm trying to compile a programme which uses LibTorch for android. But the libraries built by script/build_android.sh in the pytorch repo, ...
Read more >
(Prototype) Introduce lite interpreter workflow in Android and iOS
Prepare model: Prepare the lite interpreter version of model by run the script ... Build libtorch lite for android: Build libtorch for android...
Read more >
PyTorch Mobile Now Supports Android NNAPI - Medium
This initial release includes fully-functional support for a small but ... and run using PyTorch Mobile's Java API or the libtorch C++ API....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found