Skip to content

🐛 [Bug] 0-D Tensor input for TensorRT subgraph is usually on cpu, not cuda #1446

Closed
@Njuapp

Description

@Njuapp

Bug Description

When encountered aten::Int operations, the graph is usually partitioned, and the TensorRT subgraph may accept a 0-D Tensor as its input. This 0-D Tensor input is usually put on CPU, not cuda, as it is done so on Torchscript/Torch.

To Reproduce

Traceback (most recent call last):
File "reproduce.py", line 39, in
trt_output = trt_model(img_input)
File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: [Error thrown at core/runtime/execute_engine.cpp:87] Expected inputs[pyt_idx].is_cuda() to be true but got false
Expected input tensors to have device cuda, found device cpu

Expected behavior

Environment

Build information about Torch-TensorRT can be found by turning on debug messages

  • Torch-TensorRT Version (e.g. 1.0.0):
  • PyTorch Version (e.g. 1.0):
  • CPU Architecture:
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, libtorch, source):
  • Build command you used (if compiling from source):
  • Are you using local sources or building from archives:
  • Python version:
  • CUDA version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions