applying artificial intelligence to product development€¦ · 21 nvidia ngc & dgx supports...

48
1 © 2019 The MathWorks, Inc. Applying Artificial Intelligence to Product Development Arvind Jayaraman, Senior Application Engineering

Upload: others

Post on 28-May-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

1© 2019 The MathWorks, Inc.

Applying Artificial Intelligence to Product Development

Arvind Jayaraman, Senior Application Engineering

Page 2: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

3

Diverse Set of Automotive Customers use MATLAB for AI

Veoneer

Radar Sensor Verification

Musashi Seimitsu

Automotive Part Defect Detection

Caterpillar

Cloud Based Data Labeling Alpine

Ground Detection

Page 3: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

4

Outline

Ground Truth Labeling Network Design and Training

CUDA and TensorRT Code Generation

Jetson Xavier and DRIVE Xavier Targeting

Key TakeawaysOptimized CUDA and TensorRT code generation Jetson Xavier and DRIVE Xavier targetingProcessor-in-loop(PIL) testing and system integration

Key TakeawaysPlatform Productivity: Workflow automation, ease of use Framework Interoperability: ONNX, Keras-TensorFlow, Caffe

Page 4: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

5

Example Used in Today’s Talk

Lane Detection Network

Co-ordinate Transform

Bounding Box Processing

AI Application

YOLOv2 Network

Page 5: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

6

Outline

Ground Truth Labeling Network Design and Training

CUDA and TensorRT Code Generation

Jetson Xavier and DRIVE Xavier Targeting

Page 6: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

7

Ground Truth LabelingUnlabeled Training Data Labels for Training

Page 7: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

8

Interactive Tools for Ground Truth Labeling

ROI Labels• Bound boxes• Pixel labels • Poly-lines

Scene Labels

Page 8: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

9

Automate Ground Truth Labeling

Pre-built Automation

User authored automation

Page 9: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

10

Automating Labeling of Lane Markers

Page 10: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

11

Automate Labeling of Bounding Boxes for Vehicles

Page 11: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

12

Export Labeled Data for Training

Bounding Boxes Labels

Polyline Labels

Page 12: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

13

Outline

Ground Truth Labeling Network Design and Training

CUDA and TensorRT Code Generation

Jetson Xavier and DRIVE Xavier Targeting

Page 13: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

14

Example Used in Today’s Talk

Lane Detection Network

Co-ordinate Transform

Bounding Box Processing

AI Application

YOLOv2 Network

Page 14: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

15

Lane Detection Algorithm

Pretrained Network (E.g. AlexNet)

Modify Network for

Lane DetectionCoefficients of parabola

Transform to

Image Coordinates

Page 15: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

16

Lane Detection: Load Pretrained Network

Lane Detection Network▪ Regression CNN for lane parameters ▪ MATLAB code to transform to image co-ordinates

>> net = alexnet

>> deepNetworkDesigner

Page 16: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

17

View Network in Deep Network Designer App

Page 17: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

18

Remove Layers from AlexNet

Page 18: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

19

Add Regression Output for Lane Parameters

Regression Output for

Lane Coefficients

Page 19: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

20

Transparently Scale Compute for Training

Specify Training on:

Quickly change training hardware

Works on Windows

(no additional setup)

Page 20: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

21

NVIDIA NGC & DGX Supports MATLAB for Deep Learning

▪ GPU-accelerated MATLAB Docker container for deep learning

– Leverage multiple GPUs on NVIDIA DGX Systems and in the Cloud

▪ Cloud providers include: AWS, Azure, Google, Oracle, and Alibaba

▪ NVIDIA DGX System / Station

– Interconnects 4/8/16 Volta GPUs in one box

▪ Containers available for R2018a and R2018b– New Docker container with every major release (a/b)

▪ Download MATLAB container from NGC Registry– https://ngc.nvidia.com/registry/partners-matlab

Page 21: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

22

Evaluate Lane Boundary Detections vs. Ground Truth

evaluateLaneBoundaries

Page 22: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

23

Example Used in Today’s Talk

Lane Detection Network

Co-ordinate Transform

Bounding Box Processing

AI Application

YOLOv2 Network

Page 23: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

24

YOLO v2 Object Detection

Pretrained Network Feature Extractor ( E.g. ResNet 50)

Detection SubnetworkYOLO CNN Network Decode Predictions

Page 24: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

25

Model Exchange with MATLAB

PyTorch

Caffe2

MXNet

Core ML

CNTK

Keras-

Tensorflow

Caffe

MATLABONNX

Open Neural Network Exchange

Page 25: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

26

Import Pretrained Network in ONNX Format

Page 26: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

27

Import Pretrained Network in ONNX Format

Page 27: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

28

Modify Network

imageInputLayer replaces the input and subtraction layer

Removing the 2 ResNet-50 layers

Save MAT file for code gen

Page 28: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

29

YOLOv2 Detection Network

▪ yolov2Layers: Create network architecture

>> lgraph = yolov2Layers(imageSize, numClasses, anchorBoxes, network, featureLayer)

Number of Classes

Pretrained Feature Extractor

>> detector = trainYOLOv2ObjectDetector(trainingData,lgraph,options)

Page 29: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

30

Evaluate Performance of Trained Network

▪ Set of functions to evaluate trained

network performance

– evaluateDetectionMissRate

– evaluateDetectionPrecision

– bboxPrecisionRecall

– bboxOverlapRatio

>> [ap,recall,precision] =

evaluateDetectionPrecision(results,vehicles(:,2));

evaluateDetectionPrecision

bboxPrecisionRecall

Page 30: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

31

Example Applications using MATLAB for AI Development

Lane Keeping Assist using

Reinforcement LearningOccupancy Grid Creation

using Deep Learning

Lidar Segmentation with

Deep Learning

Page 31: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

32

Outline

Ground Truth Labeling Network Design and Training

CUDA and TensorRT Code Generation

Jetson Xavier and DRIVE Xavier Targeting

Key TakeawaysPlatform Productivity: Workflow automation, ease of use Framework Interoperability: ONNX, Keras-TensorFlow, Caffe

Page 32: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

33

GPU Coder runs a host of compiler transforms to generate CUDA

Control-flow graph

Intermediate representation

(CFG – IR)

….

….

CUDA kernel

optimizations

Front – end

Traditional compiler

optimizations

MATLAB Library function mapping

Parallel loop creation

CUDA kernel creation

cudaMemcpy minimization

Shared memory mapping

CUDA code emission

Scalarization

Loop perfectization

Loop interchange

Loop fusion

Scalar replacement

Loop

optimizations

Page 33: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

34

Example Used in Today’s Talk

Lane Detection Network

Co-ordinate Transform

Bounding Box Processing

AI Application

YOLOv2 Network

Optimized TensorRT Code for Models

Page 34: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

35

Trained Network

FusedLayer

FusedLayer

FusedLayer

FusedLayer FusedLayer

Optimized Network TensorRT Engine

Page 35: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

36

Code generation workflow (demo)

Deployment

unit-test

Desktop

GPU

.mex

Build type

Call compiled

application from

MATLAB directly

Page 36: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

37

Page 37: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

38

With GPU Coder, MATLAB is fast

Faster than TensorFlow,

MXNet, and PyTorch

Intel® Xeon® CPU 3.6 GHz - NVIDIA libraries: CUDA10 - cuDNN 7 - Frameworks: TensorFlow 1.13.0, MXNet 1.4.0 PyTorch 1.0.0

Page 38: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

39

TensorRT speeds up inference for TensorFlow and GPU Coder

TensorFlow

GPU Coder

Page 39: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

40

GPU Coder with TensorRT faster across various Batch Sizes

Batch Size

GPU Coder + TensorRT

TensorFlow + TensorRT

Intel® Xeon® CPU 3.6 GHz - NVIDIA libraries: CUDA10 - cuDNN 7 – Tensor RT 5.0.2.6. Frameworks: TensorFlow 1.13.0, MXNet 1.4.0 PyTorch 1.0.0

Page 40: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

41

Even higher Speeds with Integer Arithmetic (int8)

Batch Size

GPU Coder + TensorRT (fp32)

TensorFlow + TensorRT

GPU Coder + TensorRT (int8)

TensorFlow (int8)

Intel® Xeon® CPU 3.6 GHz - NVIDIA libraries: CUDA10 - cuDNN 7 – Tensor RT 5.0.2.6. Frameworks: TensorFlow 1.13.0, MXNet 1.4.0 PyTorch 1.0.0

Page 41: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

42

Outline

Ground Truth Labeling Network Design and Training

CUDA and TensorRT Code Generation

Jetson Xavier and DRIVE Xavier Targeting

Key TakeawaysOptimized CUDA and TensorRT code generation

Page 42: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

43

Deploy to Jetson and Drive

MATLAB algorithm

(functional reference)

Functional test1 Deployment

unit-test

2

Desktop

GPU

.mex

Build type

Call compiled

application from

MATLAB directly

C++

Deployment

integration-test

3

Desktop

GPU

.lib

Call compiled

application

from hand-coded

main()

Real-time test4

Embedded GPU

Deploy to target

Deploy to target

and run with

hardware-in-loop

Page 43: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

44

Stream Webcam Images from HW

Run modelin MATLAB

Update parameters

Deploy and launch on Target hardware

Model + Code

▪ Generate CUDA and TensorRT code

▪ Deploy and build on target

▪ Launch executable on the target.

Jetson/DRIVE

Hardware in the loop workflow with Jetson/DRIVE device

Results for Verification

MATLAB

Page 44: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

45

Page 45: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

46

Deploying DNN application to Jetson/Drive device

Target Display

Host Machine

Video Feed

Deployable MATLAB

algorithm code

Page 46: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

47

Processor in the loop verification with Jetson/Drive devices

Generates a wrapper

detect_lane_yolo_full_pil

Page 47: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

48

Outline

Ground Truth Labeling Network Design and Training

CUDA and TensorRT Code Generation

Jetson Xavier and DRIVE Xavier Targeting

Key TakeawaysOptimized CUDA and TensorRT code generation Jetson Xavier and DRIVE Xavier targetingProcessor-in-loop(PIL) testing and system integration

Key TakeawaysPlatform Productivity: Workflow automation, ease of use Framework Interoperability: ONNX, Keras-TensorFlow, Caffe

Page 48: Applying Artificial Intelligence to Product Development€¦ · 21 NVIDIA NGC & DGX Supports MATLAB for Deep Learning GPU-accelerated MATLAB Docker container for deep learning –Leverage

49

Thank You