kalfazed / tensorrt_starter

This repository give a guidline to learn CUDA and TensorRT from the beginning.
141 stars 38 forks source link

tenosrrt C++ api 加载带有自定义plugin的engine #9

Open wutheringcoo opened 2 months ago

wutheringcoo commented 2 months ago

halo.韩博 请教个问题, 我已经通过trtexec --plugin 生成了带有自定义plugin的engine 那么如何在C++ api中调用该plugin呢, 我把这段:

void* pluginLibraryHandle = dlopen( "/path/to/plugin.so", RTLD_LAZY); nvinfer1::IPluginRegistry* pluginRegistry = getPluginRegistry(); nvinfer1::IPluginCreator* plugincreator = pluginRegistry->getPluginCreator("pluginname", "1"); plugincreator->createPlugin("pluginname", nullptr); initLibNvInferPlugins(&gLogger, ""); runtime_ = nvinfer1::createInferRuntime(gLogger); engine_ = runtime_->deserializeCudaEngine(engine_data.data(), engine_data.size(), nullptr); context_ = engine_->createExecutionContext();

但是推理的时候还是没有看到期望的自定义plugin log,如下: Plugin creator already registered - ::CustomerPluginname version 1

上面的步骤是有啥问题不?