You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import torch
import torchvision.models as models
import torch_tensorrt
# get inception_v3 pretrained model
# It also implicitly sets transform_input=True which causes Double type issue during the compilation
model = models.inception_v3(pretrained=True).eval()
x = torch.rand(1, 3, 299, 299)
y=model(x)
tmodel = torch.jit.trace(model, x)
trt_model = torch_tensorrt.compile(tmodel,
inputs= [torch_tensorrt.Input((1, 3, 299, 299))]
)
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/lib/python3.8/site-packages/torch_tensorrt/_compile.py", line 115, in compile
return torch_tensorrt.ts.compile(ts_mod, inputs=inputs, enabled_precisions=enabled_precisions, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/torch_tensorrt/ts/_compiler.py", line 116, in compile
compiled_cpp_mod = _C.compile_graph(module._c, _parse_compile_spec(spec))
RuntimeError: [Error thrown at core/util/trt_util.cpp:283] Expected type to be true but got false
Unsupported ATen data type Double
Environment
Build information about Torch-TensorRT can be found by turning on debug messages
I use the latest Nvidia PyTorch Docker Image nvcr.io/nvidia/pytorch:22.04-py3.
docker run -ti --gpus all \
--ipc=host --ulimit memlock=-1 --ulimit stack=67108864 \
nvcr.io/nvidia/pytorch:22.04-py3
Fixed _transform_input() where I explicitly wrap constants with float32 tensors. It works, but PyTorch developers usually do not write models code this way.
Bug Description
To Reproduce
Steps to reproduce the behavior:
Error:
Environment
Additional context
To solve the issue I need to replace existing inception model method
_transform_input()
with a fixed oneExisting
_transform_input()
methodFixed
_transform_input()
where I explicitly wrap constants with float32 tensors. It works, but PyTorch developers usually do not write models code this way.Is it possible to ask
torch.jit.trace
to automatically wrap constants with float32 tensors?tmodel.graph
showsDouble
for the original modelfor the fixed model (with fixed
_transform_input()
method) it showsFloat
- which works for TRT compilerThe text was updated successfully, but these errors were encountered: