Skip to content

❓ [Question] Unknown type name '__torch__.torch.classes.tensorrt.Engine' #632

@yokosyun

Description

@yokosyun

❓ Question

when I tried to load trt module which saved with python

torch::jit::load(trtorch_path);

I got this error

terminate called after throwing an instance of 'torch::jit::ErrorReport'
  what():  
Unknown type name '__torch__.torch.classes.tensorrt.Engine':
Serialized   File "code/__torch__/models/backbone.py", line 4
  __parameters__ = []
  __buffers__ = []
  __torch___models_backbone_Backbone_trt_engine_ : __torch__.torch.classes.tensorrt.Engine
                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
  def forward(self_1: __torch__.models.backbone.Backbone_trt,
    input_0: Tensor) -> Tensor:

I linked libtrtorch.so as bellow

target_link_libraries(
    ${ProjectTargetLibName}
    PRIVATE
        ${TORCH_LIBRARIES}
        /opt/trtorch/lib/libtrtorch.so
)

maybe I need to compile trt_module in c++ instead of python??

What you have already tried

I can save trt_module and load and run with python without any problem

Environment

  • PyTorch 1.9
  • Libtorch 1.9
  • OS (Linux):
  • CUDA 11.0:
  • TensorRT 8.0
  • TRTorch 0.4(libtrtorch-v0.4.0-cudnn8.2-tensorrt8.0-cuda11.1-libtorch-1.9.0.tar.gz)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions