How to increase GPU Utilization for inference

Divyam: <p>I am trying to use Pytorch-MTCNN with multiple camera<br>
My setup is 2 webcams and 1 RTSP camera even though each process is just using 800Mbs of GPU Memory, the FPS is dropping drastically from 30 FPS using one camera to 20 when using two to 8-10 when using three video streams.</p>
<p>Specs<br>
CPU - Intel i7 9th gen 12 cores<br>
GPU - RTX 2070 8 GB<br>
RAM - 16 GB<br>
SSD - 512 GB<br>
HDD - 1 TB<br>
Here’s the screenshot of nvidia-smi<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/e/2edd5f57385995a40a8cf923a5a9ddcd45523f2e.png" data-download-href="https://discuss.pytorch.org/uploads/default/2edd5f57385995a40a8cf923a5a9ddcd45523f2e" title="Screenshot from 2020-08-18 13-53-02"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/e/2edd5f57385995a40a8cf923a5a9ddcd45523f2e_2_690x388.png" alt="Screenshot from 2020-08-18 13-53-02" data-base62-sha1="6GAfCcolpGsLIuzI4HYYkUaAav4" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/e/2edd5f57385995a40a8cf923a5a9ddcd45523f2e_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/3X/2/e/2edd5f57385995a40a8cf923a5a9ddcd45523f2e_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/2/e/2edd5f57385995a40a8cf923a5a9ddcd45523f2e_2_1380x776.png 2x" data-dominant-color="262A2C"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot from 2020-08-18 13-53-02</span><span class="informations">1920×1080 87.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<pre><code class="lang-auto">from facenet_pytorch import MTCNN, InceptionResnetV1
import torch
import os
import cv2
import time 
#workers = 0 if os.name == 'nt' else 4

os.environ['DISPLAY'] = ':0'
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
print('Running on device: {}'.format(device))
mtcnn = MTCNN(
    image_size=160, margin=30, min_face_size=50,
    thresholds=[0.6, 0.7, 0.7], factor=0.709, post_process=True,
    device=device)




#cap = cv2.VideoCapture('rtsp://admin:incerno123@192.168.1.36:554/cam/realmonitor?channel=1&amp;subtype=0&amp;unicast=true&amp;proto=Onvif')
#cap = cv2.VideoCapture('rtsp://admin:123456@192.168.1.10:554/H264?ch=1&amp;subtype=0&amp;proto=Onvif')
cap = cv2.VideoCapture(0)
while(True):
    start_fps = time.time()
    # Capture frame(-by-frame
    ret, frame = cap.read()

    # Our operations on the frame come here
    img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    #img = Image.fromarray(img)
    boxes, probs, landmarks = mtcnn.detect(img, landmarks=True)
    if boxes is not None:

        for (j,i,k) in zip(probs,boxes,landmarks):
            if j&gt;=0.55:
                xmin,ymin,xmax,ymax = i
                #print(xmin,ymin,xmax,ymax)
                img = cv2.rectangle( img , (xmin, ymin) , (xmax, ymax) , (0,255,0) , 2 )

    # Display the resulting frame
    img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
    img = cv2.resize(img , (1280, 1080))
    cv2.imshow('frame',img)
    #cv2.imshow('face',img)
    if cv2.waitKey(1) &amp; 0xFF == ord('q'):
        break
    end_fps = time.time()
    print(1/(end_fps-start_fps)) 
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

</code></pre>