Ssd.pytorch: Why the live.py run so slow on GPU?

Created on 21 Nov 2018  路  7Comments  路  Source: amdegroot/ssd.pytorch

I run the live.py for detection on webcamera, I have assign True for "--cuda", and the model was inferenced on GPU because I have notice the GPU mempry usage when run live.py.
Why did I get such a low FPS on GPU?

[INFO] starting threaded video stream...
[INFO] elasped time: 48.21
[INFO] approx. FPS: 1.14

Most helpful comment

@kebijuelun

Setting the default value of cuda arg to True will not change anything as the live.py code doesn't seem to be using it.

What I did was:

  1. Add the following after this line https://github.com/amdegroot/ssd.pytorch/blob/master/demo/live.py#L24
    if args.cuda: x = x.cuda()
  1. Add the following after this line
    https://github.com/amdegroot/ssd.pytorch/blob/master/demo/live.py#L76
    if torch.cuda.is_available(): if args.cuda: torch.set_default_tensor_type('torch.cuda.FloatTensor') if not args.cuda: print("WARNING: It looks like you have a CUDA device, but aren't using \ CUDA. Run with --cuda for optimal eval speed.") torch.set_default_tensor_type('torch.FloatTensor') else: torch.set_default_tensor_type('torch.FloatTensor')

All 7 comments

because the python code live.py does not implement the cuda version by default , have you change the code?

because the python code live.py does not implement the cuda version by default , have you change the code?

Thanks for your reply, I also found live.py doesn't implement on GPU by default,I will try to change the code to run on GPU.

I have implement the live.py on GPU, however the FPS only reached 18FPS on a single 1080GPU, it is much slower than the 45FPS which mentioned by the author.
Why did this happen? Does anyone have some ideas? @liyupeng-ing

[INFO] elasped time: 31.67
[INFO] approx. FPS: 18.76

@kebijuelun

Setting the default value of cuda arg to True will not change anything as the live.py code doesn't seem to be using it.

What I did was:

  1. Add the following after this line https://github.com/amdegroot/ssd.pytorch/blob/master/demo/live.py#L24
    if args.cuda: x = x.cuda()
  1. Add the following after this line
    https://github.com/amdegroot/ssd.pytorch/blob/master/demo/live.py#L76
    if torch.cuda.is_available(): if args.cuda: torch.set_default_tensor_type('torch.cuda.FloatTensor') if not args.cuda: print("WARNING: It looks like you have a CUDA device, but aren't using \ CUDA. Run with --cuda for optimal eval speed.") torch.set_default_tensor_type('torch.FloatTensor') else: torch.set_default_tensor_type('torch.FloatTensor')

@raviv it works

@raviv good person, you will happiness forever,ThankYou all

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oarriaga picture oarriaga  路  4Comments

JingpengSun picture JingpengSun  路  4Comments

xinyu1214 picture xinyu1214  路  5Comments

luhc15 picture luhc15  路  6Comments

FostorHUNT picture FostorHUNT  路  4Comments