Skip to content
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

outputs are different for torch and trt #15

Open
pkraison opened this issue Jun 27, 2020 · 15 comments
Open

outputs are different for torch and trt #15

pkraison opened this issue Jun 27, 2020 · 15 comments

Comments

@pkraison
Copy link
Contributor

pkraison commented Jun 27, 2020

i'm getting a weird output with tensorrt, for the same image torch is giving good results. any help would be appreciated

@TrojanXu
Copy link
Owner

FP16 or FP32? How about the max_diff printed by main.py?

@pkraison
Copy link
Contributor Author

Traceback (most recent call last):
File "/media/ssd/yolov5N/yolov5-tensorrt/main.py", line 222, in
diff = abs(a-b)
ValueError: operands could not be broadcast together with shapes (1,214200,7) (1,17640,7)
Segmentation fault (core dumped)
I'm using default FP32

@TrojanXu
Copy link
Owner

Can you provide the image for reproduction?

@pkraison
Copy link
Contributor Author

okay, I'm getting a max difference of 0.0007 between torch and tensorrt. But when I'm passing the array to nms, it's giving none

@pkraison
Copy link
Contributor Author

how can I visualize the results

@TrojanXu
Copy link
Owner

That's strange. You can create a torch tensor from the numpy array and feed the tensor to nms module. I'm planning to implement it in following days.

@pkraison
Copy link
Contributor Author

pkraison commented Jun 28, 2020 via email

@imprashr
Copy link

it's working fine but when i try to infer over a directory of images, it gives pycuda error after 8 images

@TrojanXu
Copy link
Owner

TrojanXu commented Jul 3, 2020

I've implemented NMS now. For previous shape mismatch problem, I think it's caused by variant shapes of images. Torch model can adapt to that, but TRT only supports fixed input size.

@TrojanXu
Copy link
Owner

TrojanXu commented Jul 3, 2020

it's working fine but when i try to infer over a directory of images, it gives pycuda error after 8 images

Did you call allocate buffers for multiple times? Maybe you run into OOM error on GPU.

@wudashuo
Copy link

Hello, I've met exactly the same problem.
This is the inference from the original .pt file(yolov5l), it looks fine:
微信图片_20200731155029

And after I convert pt to onnx, the inference became wired, some output numbers are smaller than 0.
I tried the original pt file replacing nn.Upsample with Upsample, it also became wired, the inference is almost exactly the same with the onnx:
微信图片_20200731155022

Is replacing nn.Upsample that caused the problem?
Should I replace nn.Upsample with your Upsample and retrain yolov5 from the beginning?

@orangeccc
Copy link

same problem as @wudashuo

@wudashuo
Copy link

wudashuo commented Aug 6, 2020

same problem as @wudashuo

yolov5现在release2.0版了,然后Tutorials里也有TensorRT Deployment了,你可以去看看,我已经成功了,检测也正常了,但是必须用最新的代码重新训练模型,因为2.0的模型结构变了。

@orangeccc
Copy link

yolov5现在release2.0版了,然后Tutorials里也有TensorRT Deployment了,你可以去看看,我已经成功了,检测也正常了,但是必须用最新的代码重新训练模型,因为2.0的模型结构变了。

好的,谢谢。

@TrojanXu
Copy link
Owner

TrojanXu commented Oct 4, 2020

Updated to v3.0. Upsample is no longer needed to be replaced. Note that, the GPU NMS is different from the default NMS in pytorch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants