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

发现一个问题,在实际跑的时候前面两张速度很慢 #50

Open
CGump opened this issue Aug 3, 2021 · 5 comments
Open

发现一个问题,在实际跑的时候前面两张速度很慢 #50

CGump opened this issue Aug 3, 2021 · 5 comments

Comments

@CGump
Copy link

CGump commented Aug 3, 2021

不知道是什么原因,我设置的是一张图一张图过的,有的模型第一张图要7.8秒时间,第二张图也要1.2秒,有的模型第一张图几百毫秒,第二张图最高甚至要30秒。但是很奇怪的是,过了前两张图就全部正常了,总体时间也就几十毫秒左右。

不知道有没有遇到相同问题的,找到原因的,推理时间这块要找原因无从下手啊!

@CGump
Copy link
Author

CGump commented Aug 3, 2021

过程1是前处理,过程2就是模型推理,过程3是后处理接输出那块。也就是torch::jit::IValue output = module.forward(inputs);这一步

Device type is: cuda
过程1时间: 16 ms
过程2时间: 263 ms
过程3时间: 12 ms
---------------------------------
过程1时间: 10 ms
过程2时间: 11477 ms
过程3时间: 13 ms
---------------------------------
过程1时间: 12 ms
过程2时间: 7 ms
过程3时间: 16 ms
---------------------------------
过程1时间: 5 ms
过程2时间: 7 ms
过程3时间: 18 ms
---------------------------------
过程1时间: 5 ms
过程2时间: 7 ms
过程3时间: 14 ms
---------------------------------
过程1时间: 5 ms
过程2时间: 7 ms
过程3时间: 16 ms
---------------------------------
过程1时间: 5 ms
过程2时间: 7 ms
过程3时间: 16 ms
---------------------------------
过程1时间: 5 ms
过程2时间: 7 ms
过程3时间: 22 ms
---------------------------------
过程1时间: 5 ms
过程2时间: 7 ms
过程3时间: 19 ms
---------------------------------

@programcj
Copy link

我也遇到了相同的问题, 还有加载到多个GPU的时候 需要修改 load(,CUDA,index) 如果 model_.to(cuda) 是不行的

@CGump
Copy link
Author

CGump commented Oct 9, 2021

我也遇到了相同的问题, 还有加载到多个GPU的时候 需要修改 load(,CUDA,index) 如果 model_.to(cuda) 是不行的

是的,很奇怪的前两帧,有的模型是第一帧慢,有的是第二帧慢

@jiang16
Copy link

jiang16 commented Mar 29, 2022

好像是warm up的原因,我也发现了这个问题,实际应用时提前推理两张预热一下模型

@zhiqwang
Copy link

pytorch 1.9的问题,升级到最新版可能会好一些

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

4 participants