r/pytorch • • May 26 '21

Tutorial: Pruning and Quantizing PyTorch YOLOv3 for Real-time Laptop Performance

39 Upvotes

6 comments sorted by

4

u/markurtz May 26 '21

We walked around Boston carrying a Yoga C940 laptop, running in real time using a pruned and quantized YOLOv3 model. Kaito, the dog, was an excited and willing participant - no dogs (or neural networks) were harmed in making this video. The results were impressive; here’s what we got:

  • 60.4 [email protected] on COCO (640x640 input image size)

  • 13.4 MB on disk (14.5x compression)

  • 20 fps on four-core CPU (11x faster than PyTorch at 540x540 input image size)

Apply the sparse-quantized results to your dataset by following the YOLOv3 tutorial. All software is open source or freely available.

2

u/mcampbell42 May 26 '21

Any down sides ? Also can you run this on a gpu also to be even faster ?

3

u/markurtz May 26 '21

We do drop a little bit on mAP through the pruning and quantization from 64.2 baseline to 60.4 (roughly 2 mAP for pruning and 2 mAP for the additional quantization).

Converting the model to tensorRT would enable speedup on the newer A100 chips through sparsity and quantization. Other GPUs, unfortunately, don't have support for speeding up less structured sparsity patterns other than channel and filter pruning. Both we are actively looking into to show how they can be done through the open-source tooling!

1

u/mcampbell42 May 27 '21

Ah A100 less likely to need this. We are running our models on embedded computers like Jetson Nano and Xaviar so massive speed ups are really nice.

1

u/Hmolds May 26 '21

Tested on low power devices such as Raspberry Pi and Jetson Nano?

1

u/markurtz May 26 '21

Currently, we only support x86 CPU architectures, so mainly server and laptop/desktop deployments on Intel and AMD chips. We are actively looking into supporting ARM in the medium term, though, for the low power edge deployments. Stay tuned for that!