-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terrible TensorRT accuracy when running inference on an object tracking algorithm #3609
Comments
Could you please check this quickly with polygraphy? The usage would be like You can feed real input too, see https://github.com/NVIDIA/TensorRT/tree/main/tools/Polygraphy/examples/cli/run/05_comparing_with_custom_input_data |
Thank you @zerollzeng, here is the answer: D:\pyth\pytracking-master>polygraphy run modified_latest3_sanitized2.onnx --trt --onnxrt accuracy seems to pass the tests, but when I insert the tensorrt model inside the code, the tracking box in is all over the place on the webcam feed. When I run the model with onnxruntime inside my code, the tracking seems fine, but when I switch to run the engine, everything is not fine... If you want I can record a video sample, of how the model runs on pytorch, on onnxruntime and trt I ran Polygraphy inspect log file modified_latest_3_sanitized2_inspect.txt |
Did you sync after each inference? or a bug in the pre or post processing?
int64 weights should be good. |
@zerollzeng What do you mean by this question?
|
I was using polygraphys inference, everything was fixed, when I transfered tensors from gpu to cpu before inference! |
Description
I am trying to convert the inference part of the pytracking tomp101 algorithm to tensorrt
I've converted it to onnx, the inference seems to be fine, the bounding box catches on correctly ALTHOUGH comparing the difference between output tensors of the original model and onnx model using this code seem to differ by quite a lot (the tensor values seem to differ, but tracks objects just fine :D ):
{sample_x [dtype=float32, shape=(1, 1024, 18, 18)],
train_samples [dtype=float32, shape=(1, 1024, 18, 18)],
target_labels [dtype=float32, shape=(1, 1, 18, 18)],
train_ltrb [dtype=float32, shape=(1, 4, 18, 18)]}
[I] trt-runner-N0-01/18/24-04:45:38
---- Inference Output(s) ----
{bbreg_test_feat_enc [dtype=float32, shape=(1, 1, 256, 18, 18)],
bbreg_weights [dtype=float32, shape=(1, 256, 1, 1)],
target_scores [dtype=float32, shape=(1, 1, 18, 18)]}
r1 = original_model(inputs)
r2 = session.run(inputs)
avg11=avg11+(torch.mean(torch.abs(r1[0] - torch.from_numpy(r2[0]).cuda())))
avg12=avg12+(torch.mean(torch.abs(r1[1] - torch.from_numpy(r2[1]).cuda())))
avg13=avg13+(torch.mean(torch.abs(r1[2] - torch.from_numpy(r2[2]).cuda())))
print(avg11/30)
print(avg12/30)
print(avg13/30)
BUT
when the model is converted to TensorRT the accuracy drops!!! inference is terrible.
Does anybody have any suggestions on how to improve it? Maybe should I modify the onnx model with graph surgeon? maybe theres some polygraphy tool that I could use?
Maybe there is a trtexec method of converting that preserves accuracy?
THANK YOU
Environment
TensorRT Version: 8.6
NVIDIA GPU: GTX 1660 Ti
NVIDIA Driver Version: 546.01
CUDA Version: 12.1
CUDNN Version: 8.9.7
Operating System:
Python Version (if applicable): 3.10.13
PyTorch Version (if applicable): 2.1.2+cu121
Baremetal or Container (if so, version): no environment
Relevant Files
Model link: https://drive.google.com/file/d/1rKmrrktevdtL9Namevg3XdpMXWjTc3Gv/view?usp=sharing
The text was updated successfully, but these errors were encountered: