GithubHelp home page GithubHelp logo

Comments (11)

jaybdub avatar jaybdub commented on August 23, 2024

Hi Wallace00V,

Thanks for reaching out! Yes, you can by serializing the TensorRT engine and executing using the TensorRT C++ runtime.

Assume you optimized your model by calling

model_trt = torch2trt(model, [data])

The model_trt is a TRTModule, which contains an attribute engine which is the TensorRT engine. You can serialize this engine and save it to the path model_trt.engine disk by calling

with open('model_trt.engine', 'wb') as f:
    f.write(model_trt.engine.serialize())

This serialized engine may be used with the TensorRT C++ runtime as described in the TensorRT Developer Guide.

If you're unfamiliar with using TensorRT directly, please let me know and I'd be happy to help.

Best,
John

from torch2trt.

Wallace00V avatar Wallace00V commented on August 23, 2024

@jaybdub
thx for your answer, but i am unfamiliar with TensorRT. Please, how to load the 'model_trt.engine' in TensorRT C++ runtime?

from torch2trt.

Wallace00V avatar Wallace00V commented on August 23, 2024

@jaybdub all right, i figured it out just like the following:

std::stringstream gieModelStream; 
gieModelStream.seekg(0, gieModelStream.beg); 
std::ifstream cache( "model_trt.engine" ); 
gieModelStream << cache.rdbuf();
 cache.close(); 
IRuntime* runtime = createInferRuntime(gLogger); 
assert(runtime != nullptr); 
gieModelStream.seekg(0, std::ios::end);
 const int modelSize = gieModelStream.tellg(); 
gieModelStream.seekg(0, std::ios::beg);
 void* modelMem = malloc(modelSize); 
gieModelStream.read((char*)modelMem, modelSize);
 nvinfer1::ICudaEngine* engine = runtime->deserializeCudaEngine(modelMem, modelSize, NULL); assert(engine != nullptr); 
free(modelMem);

from torch2trt.

TheLittleBee avatar TheLittleBee commented on August 23, 2024

@jaybdub
Hi.
I got an error while using TensorRT C++ to deserialize the engine, which has some interpolate layers.

[TensorRT] ERROR: Cannot deserialize plugin interpolate
Segmentation fault

How to fix that?

from torch2trt.

donghoonsagong avatar donghoonsagong commented on August 23, 2024

I have the same error that is occured in deserializing the engine in C++

ERROR: Cannot deserialize plugin interpolate.

from torch2trt.

Raneee avatar Raneee commented on August 23, 2024

have the same error that is occured in deserializing the engine in C++. Do you solve the problem? @TheLittleBee @donghoonsagong

from torch2trt.

xieydd avatar xieydd commented on August 23, 2024

same problem , may be need a pluginFactory, have you solve the problem?
@donghoonsagong @Raneee @TheLittleBee @Wallace00V @jaybdub

from torch2trt.

skyler1537 avatar skyler1537 commented on August 23, 2024

same problem I believe: [TensorRT] ERROR: getPluginCreator could not find plugin interpolatetorch2trt version 1 namespace torch2trt

from torch2trt.

crazybob23 avatar crazybob23 commented on August 23, 2024

@skyler1253 @xieydd @Raneee @donghoonsagong @TheLittleBee @Wallace00V @jaybdub
Same problem. I can deserialize it in Python but failed in Cpp. Have you any ideas?

from torch2trt.

zbz-cool avatar zbz-cool commented on August 23, 2024

@skyler1253 @xieydd @Raneee @donghoonsagong @TheLittleBee @Wallace00V @jaybdub @crazybob23
same problem, do you solve this problem?

from torch2trt.

DYJNG avatar DYJNG commented on August 23, 2024

@skyler1253 @xieydd @Raneee @donghoonsagong @TheLittleBee @Wallace00V @jaybdub @crazybob23 @zbz-cool
same problem, do you solve this problem?

from torch2trt.

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.