onnx / onnx/models

Low GPU utilization

Open
#136 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Hi!

I'm trying to use MTCNN face detector from this example: https://github.com/onnx/models/blob/master/models/face_recognition/ArcFace/arcface_inference.ipynb
The detector works, but GPU usage is very low, only about 14%.
And it gives out only 6 FPS for FullHD image.

Why is the detector so slow? How to make it use 100% of GPU?

Here is my code:

import time
import cv2
import mxnet as mx
import mtcnn_detector
ctx = mx.gpu()
detector = mtcnn_detector.MtcnnDetector("path_to_model", ctx=ctx)
image = cv2.imread("1920x1080.png")
frame_id = 0
time_deltas: = [0 for _ in range(10)]
while True:
    time1 = time.time()
    detector.detect_face(image)
    time2 = time.time()
    td = time2 - time1
    time_deltas[frame_id % 10] = td
    if frame_id % 10 == 0:
        fps = 1 / (sum(time_deltas) / len(time_deltas))
        print(fps)
    frame_id += 1

My system:
GPU: 2 x GTX 1050Ti, CPU: Xeon E5-2660 v2 @ 2.20GHz, RAM: 32GB
Python: Python 3.6.5, mxnet-cu91mkl, Nvidia driver: 390.48
Ubuntu 18.04

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced ArcFace inference notebook and the supplied Python loop, then inspect how mtcnn_detector.MtcnnDetector.detect_face processes the 1920x1080 image on mx.gpu(). Reproduce the reported 6 FPS and low GPU utilization with the stated environment. Done means identifying the limiting behavior and documenting or implementing a verified improvement, though the issue does not name a target file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, opencv, python
Domain
computer-vision, machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.