xzz777 / SCTNet

Official implementation of SCTNet (AAAI2024)
MIT License
146 stars 10 forks source link

infenence time #10

Open HGao-cv opened 5 months ago

HGao-cv commented 5 months ago

Why are there so many torch.cuda.synchronize() here? https://github.com/xzz777/SCTNet/blob/master/speed/torch_speed.py print('=========Speed Testing=========') torch.cuda.synchronize() torch.cuda.synchronize() tstart = time.time() for in range(iterations): segmentor(input) torch.cuda.synchronize() torch.cuda.synchronize() elapsed_time = time.time() - t_start latency = elapsed_time / iterations * 1000

xzz777 commented 5 months ago

I used the speed testing code from PIDNet and did not modify this part. In fact, STDC, DDRNet, and PIDNet all use the same PyTorch speed testing code, which includes two calls to torch.cuda.synchronize(), both before and after model inference. So, I also used it twice. You can try modifying it to use only once, this won't affect the speed. In fact, as long as you ensure that torch.cuda.synchronize() is used once before and once after the model, the measured latency will be accurate.

saddogs commented 20 hours ago

Hi, when I execute the code: "python torch_speed.py --type sctnet-b-seg100", I get the error in the image, but before that, my training code is running without any problem, and I have downloaded the corresponding version of mmcv, etc. as requested. What is the problem please, looking forward to your reply! 1720145735000