ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.19k stars 3.44k forks source link

detect.py only running on cpu not on gpu #517

Closed ksharm50 closed 5 years ago

ksharm50 commented 5 years ago

when i run this command and try to run the detection faster using GPU i am unable to do that and detec.py start running on cpu . why ? python detect.py --source 0 --cfg test.cfg --data test.data --weight test.weights --device 0

image it is running very slow . what can i do to make it run on dedicated GPU @glenn-jocher

glenn-jocher commented 5 years ago

@kunalsharmagnome PyTorch is not detecting any available GPU hardware. You need to check your CUDA installation etc. See PyTorch installation instructions.

I'm closing the issue as it's not related to this repository specifically, it's a more general pytorch install issue. See https://pytorch.org/get-started/locally/

ksharm50 commented 5 years ago

@glenn-jocher i understand this is happening that pytorch is not getting the gpu device but when i am passing < device 0 > and program is not finding the device then it should print proper warning message for better clarity because when it is running it is showing that program is running on device 0 . but thanks for the reply :)

glenn-jocher commented 5 years ago

Hmm yes a warning is a good idea here, I’ll add it as a TODO!

glenn-jocher commented 5 years ago

@kunalsharmagnome this fix has been implemented. Requesting a device on a CPU or CUDA unavailable system now produces a hard error:

/Users/glennjocher/anaconda3/envs/yolov3/bin/python /Users/glennjocher/PycharmProjects/yolov3/train.py
Traceback (most recent call last):
Namespace(accumulate=1, adam=False, arc='defaultpw', batch_size=16, bucket='', cache_images=False, cfg='cfg/yolov3-spp.cfg', data='data/coco_16img.data', device='', epochs=273, evolve=False, img_size=320, img_weights=False, multi_scale=False, name='', nosave=False, notest=False, prebias=False, rect=False, resume=False, transfer=False, var=None, weights='weights/yolov3-spp.weights')
  File "/Users/glennjocher/PycharmProjects/yolov3/train.py", line 411, in <module>
    device = torch_utils.select_device(opt.device, apex=mixed_precision)
  File "/Users/glennjocher/PycharmProjects/yolov3/utils/torch_utils.py", line 21, in select_device
    assert torch.cuda.is_available(), 'CUDA unavailable, invalid device %s requested' % device
AssertionError: CUDA unavailable, invalid device 0 requested
Zero23 commented 4 years ago

@glenn-jocher i understand this is happening that pytorch is not getting the gpu device but when i am passing < device 0 > and program is not finding the device then it should print proper warning message for better clarity because when it is running it is showing that program is running on device 0 . but thanks for the reply :)

Hi, I had same issue with training with GPU. may I know are you able to solve it in the end? I believed that I had install Pytorch properly. Butt I still cannot training with my GPU. would you mind share your solution?

glenn-jocher commented 4 years ago

@Zero23 if PyTorch can't fine a cuda device then you have environment problems unrelated to this repo. You should check your pytorch and cuda installations, or you can use a working environment such as a GCP VM or a Colab instance:

Reproduce Our Environment

To access an up-to-date working environment (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled), consider a:

Zero23 commented 4 years ago

@Zero23 if PyTorch can't fine a cuda device then you have environment problems unrelated to this repo. You should check your pytorch and cuda installations, or you can use a working environment such as a GCP VM or a Colab instance:

Reproduce Our Environment

To access an up-to-date working environment (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled), consider a:

Thank you for your reply. I was able to solve this issue. I just need to update my CUDA driver to latest version. then problem solved! Thank you so much.

glenn-jocher commented 4 years ago

@Zero23 great!