Closed SohamTamba closed 11 months ago
Hi @SohamTamba - thank you for the details. I am unable to reproduce this error on the latest main
, but I do see an error displaying when compiling with dynamic shapes, which I've reported here: #2075. When using static shapes, inference is functional on main
when I compile the model with the following arguments:
inputs_trt = [
torch_tensorrt.Input(
shape=[32, 3, 224, 224],
dtype=torch.float32,
),
]
...
torch_tensorrt.compile(
traced_model, inputs=inputs_trt, enabled_precisions=enabled_precisions, truncate_long_and_double=True,
)
Additionally, another method to try is the new torch_tensorrt.dynamo.compile
API, which can be invoked as follows:
optimized_model = torch_tensorrt.dynamo.compile(
model,
inputs=inputs_trt,
enabled_precisions=enabled_precisions,
min_block_size=10,
)
I will try to reproduce the issue under the specific build conditions you described as well, and I will follow up.
I tested the code in the described environment (PyTorch 2.0.1
, Torch-TRT 1.4.0
). I am using Ubuntu 20.04
and CUDA 11 distributions for linked PyTorch packages. I was unable to reproduce the error as described.
@SohamTamba - could you provide the debug logs from your run as well, to further diagnose the issue? These can be obtained by wrapping the compilation in the context:
with torch_tensorrt.logging.debug():
...
Hi @gs-olive Here are the logs
The Tensor RT fix you recommended still gave the same error
tensor_rt.dynamo worked - it compiled but I am yet to check if the output is correct.
Hi @SohamTamba - thank you for the logs, this is very helpful. I am working on reproducing more aspects of your environment exactly, including the CUDA, Python, and GPU versions. Could you try the run once more on your machine, with the following changes:
1. Add import faulthandler; faulthandler.enable()
to the top of the file, to gather more details about the segfault
2. Add torch_tensorrt.dump_build_info()
to the top of the file
3. Switch the context with torch_tensorrt.logging.debug():
to with torch_tensorrt.logging.graphs():
(the logs will be much longer, and will contain all graph data)
4. Use static-shape inputs, as so:
inputs_trt = [
torch_tensorrt.Input(
shape=[32, 3, 224, 224],
dtype=torch.float32,
),
]
...
torch_tensorrt.compile(
traced_model, inputs=inputs_trt, enabled_precisions=enabled_precisions, truncate_long_and_double=True,
)
To reproduce your environment, I used the following Dockerfile, which is a shortened version of the Torch-TensorRT Dockerfile:
This gives me an environment with the following versions:
Python: 3.9.11
GPU: V100
Ubuntu: 18.04
Torch: 2.0.1
Torch-TensorRT: 1.4.0
CUDA: 11.7.1
The compilation is functional for static shapes on this configuration, on my machine. I think the expanded debug logs will help to deduce the error in this case.
This issue has not seen activity for 90 days, Remove stale label or comment or this will be closed in 10 days
Bug Description
I tried to compile HuggingFace's
transformers.models.vit.modeling_vit.ViTForImageClassification
using the official instructions but it failsTo Reproduce
Error Logs
Expected behavior
Compile the model so that inference is much faster
Environment
1.4.0
2.0.1
x86_64
Ubuntu 16.04.7 LTS
conda
No
3.9.11
11.7
V100
Additional context