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
Hi! I have been using torch_tensorrt for speedup of pytorch models and have been loving it. But sometimes i face problems while conversion.
In this case, i was using segmentation-models-pytorch(smp) library.
importsegmentation_models_pytorchassmpimporttorch_tensorrtastrtimporttorchmodel=smp.create_model(
arch="fpn", # name of the architecture, e.g. 'Unet'/ 'FPN' / etc. Case INsensitive!encoder_name="mit_b0",
encoder_weights="imagenet",
in_channels=3,
classes=3,
).eval().to('cuda')
input_data=torch.randn(1,3,224,224,requires_grad=False).to('cuda')
scripted_model=torch.jit.trace(model, input_data )
trt_model=trt.compile(
scripted_model,
inputs= [trt.Input((1,3,736,1280),precision=torch.float32)],
enabled_precisions={torch.float32},truncate_long_and_double=True)
I got the following error.
WARNING:root:Given dtype that does not have direct mapping to torch (dtype.unknown), defaulting to torch.float
WARNING:torch_tensorrt._compile:Input is a torchscript module but the ir was not specified (default=dynamo), please set ir=torchscript to suppress the warning.
WARNING:root:Given dtype that does not have direct mapping to torch (dtype.unknown), defaulting to torch.float
ERROR: [Torch-TensorRT TorchScript Conversion Context] - [graphShapeAnalyzer.cpp::checkCalculationStatusSanity::1660] Error Code 2: Internal Error (Assertion !isPartialWork(p.second.symbolicRep) failed. )
ERROR: [Torch-TensorRT TorchScript Conversion Context] - [graphShapeAnalyzer.cpp::checkCalculationStatusSanity::1660] Error Code 2: Internal Error (Assertion !isPartialWork(p.second.symbolicRep) failed. )
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/home/mzcar/miniconda3/envs/tensorrt/lib/python3.10/site-packages/torch_tensorrt/_compile.py", line 208, in compile
compiled_ts_module: torch.jit.ScriptModule = torchscript_compile(
File "/home/mzcar/miniconda3/envs/tensorrt/lib/python3.10/site-packages/torch_tensorrt/ts/_compiler.py", line 156, in compile
compiled_cpp_mod = _C.compile_graph(module._c, _parse_compile_spec(spec))
RuntimeError: [Error thrown at core/conversion/converters/converter_util.cpp:270] Expected const_layer to be true but got false
This especially occurs when im using mit_b0 as backbone. for other resnet based backbone, im getting good speedups.
Hence I am not much dependant on this backbone but i would love to know why this conversion is failing. If anyone could help in this, it would be helpful.
deo-abhijit
changed the title
🐛 [Bug] Encountered bug when using Torch-TensorRT with a segmentation model
🐛 [Bug] Encountered bug when using Torch-TensorRT with a pytorch segmentation model
Oct 21, 2024
@deo-abhijit have you tried using the dynamo frontend instead of torchscript? might resolve this issue. You can still use torchscript for deployment after by tracing the compiled program with torch.jit.script
Hi! I have been using torch_tensorrt for speedup of pytorch models and have been loving it. But sometimes i face problems while conversion.
In this case, i was using segmentation-models-pytorch(smp) library.
I got the following error.
This especially occurs when im using
mit_b0
as backbone. for other resnet based backbone, im getting good speedups.Hence I am not much dependant on this backbone but i would love to know why this conversion is failing. If anyone could help in this, it would be helpful.
If anyone interested, output for
pip freeze is
The text was updated successfully, but these errors were encountered: