GithubHelp home page GithubHelp logo

Could not find any similar ops to torchvision::nms. This op may not exist or may not be currently supported in TorchScript. about yolort HOT 2 CLOSED

zhiqwang avatar zhiqwang commented on May 22, 2024
Could not find any similar ops to torchvision::nms. This op may not exist or may not be currently supported in TorchScript.

from yolort.

Comments (2)

mattpopovich avatar mattpopovich commented on May 22, 2024 2

The solution for this is to make sure you are including the following:

#include <torch/script.h>       // One-stop header; for torch::jit::load()
#include <torchvision/vision.h> // For torchvision NMS in model

If that doesn't work, I checked ldd and it looked like the torchvision library was not actually being included.

Failing executable:

# ldd path/to/failing/executable | grep torch 
        libc10.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libc10.so (0x00007fe09b466000)
        libtorch.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch.so (0x00007fe089dd3000)
        libtorch_cpu.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_cpu.so (0x00007fe07fe70000)
        libtorch_cuda.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_cuda.so (0x00007fe030163000)
        libc10_cuda.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libc10_cuda.so (0x00007fe01fe6b000)

Working executable (note libtorchvision.so):

# ldd /path/to/working/executable | grep torch
        libc10.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libc10.so (0x00007f293c174000)
        libtorchvision.so => /usr/local/lib/libtorchvision.so (0x00007f293bba4000)
        libtorch.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch.so (0x00007f293bb9f000)
        libtorch_cpu.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_cpu.so (0x00007f2931c3c000)
        libtorch_cuda.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libtorch_cuda.so (0x00007f28e1f52000)
        libc10_cuda.so => /usr/local/lib/python3.8/dist-packages/torch/lib/libc10_cuda.so (0x00007f28e16d5000)

In order for libtorchvision.so to be successfully included, I had to #include <torchvision/models/resnet.h> and then actually use that in my code:

auto model = vision::models::ResNet18( );

That was the easiest way I found to actually use something from torchvision in your code... After that, the failing executable showed libtorchvision.so with ldd and I was able to successfully load my yolov5-rt-stack model with NMS post-processing in C++! 🥳

from yolort.

zhiqwang avatar zhiqwang commented on May 22, 2024 1

Hi @mattpopovich , Thanks for the tip here, it was very useful. I had some similar ldd linking problems when I was first compiling torchvision.

from yolort.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.