pjreddie / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
25.74k stars 21.33k forks source link

2 Camera, 2 Darknet instance, 2 GPU with multiprocessing possible? #1558

Open jturi opened 5 years ago

jturi commented 5 years ago

Hi there!

Is there a way to run multiple darknet detection instances in parallel with multiprocessing? I have two 300FPS cameras connected to my PC and 2 GTX1080Ti for high speed stereo vision object detection , I have to process them in parallel but can't find a way to load 2 darknet models into separate GPUs.

# darknet/python/darknet.py
set_gpu = lib.cuda_set_device # line59 
# darknet sets the gpu with cuda, is there a way to separate GPU assignments here?

Looking for a workaround to do this:

import darknet0 as dn0
import darknet1 as dn1
dn0.set_gpu(0)    # assign GPU0
dn1.set_gpu(1)    # assign GPU1
numpy_images0 = images_from_camera0()
numpy_images1 = images_from_camera1()
Process0:
for np_image0 in numpy_images0:
    meta0 = dn0.load_meta(b"cfg/coco.data", )
    net0 = dn0.load_net(b"cfg/yolov3.cfg ", backup/yolov3.backup", 0)

    r0 = detect(net=net0, meta=meta0, image=np_image0, thresh=.6, hier_thresh=.6, nms=.45)
    ...
Process1:
for np_image1 in numpy_images1:
    net1 = dn1.load_net(b" cfg/yolov3.cfg ", backup/yolov3.backup", 0)
    meta1 = dn1.load_meta(b"cfg/coco.data", )
    r1 = detect(net=net1, meta=meta1, image=np_image1, thresh=.6, hier_thresh=.6, nms=.45)
    ...
ahmadi173 commented 4 years ago

hi, did you find any solution?

jturi commented 4 years ago

Hi ahmady, We had other urgent projects in the pipeline so I could not focus on darknet. Next month we continue with this project again. In the meantime could we leave this issue open so more people could find it?

zabir-nabil commented 4 years ago

have a look at this, it may be helpful: https://stackoverflow.com/questions/61867541/parallel-gpu-execution-with-multiple-darknet-models-in-python

yanteng commented 3 years ago

if it is possible that using multiple detection instances in one GPU? Through my testing, I found that load multiple instances in parallel will slow down the detection speed.