MathWorks - Mobile View
  • 碻形冰暨硞 MathWorks 帐憷碻形冰暨硞 MathWorks 帐憷
  • Access your MathWorks Account
    • 我的帐户
    • 我的社区资料
    • 关联许可证
    • 登出
  • 产品
  • 解决方案
  • 学术
  • 支持
  • 社区
  • 活动
  • 获取 MATLAB
MathWorks
  • 产品
  • 解决方案
  • 学术
  • 支持
  • 社区
  • 活动
  • 获取 MATLAB
  • 碻形冰暨硞 MathWorks 帐憷碻形冰暨硞 MathWorks 帐憷
  • Access your MathWorks Account
    • 我的帐户
    • 我的社区资料
    • 关联许可证
    • 登出

视频与网上研讨会

  • MathWorks
  • 视频
  • 视频首页
  • 搜索
  • 视频首页
  • 搜索
  • 联系销售
  • 试用软件
  Register to watch video
  • Description
  • Full Transcript
  • Related Resources

Deep Learning in Simulink for NVIDIA GPUs: Generate CUDA Code Using GPU Coder

Bill Chou, MathWorks

Simulink® is a trusted tool for designing complex systems that include decision logic and controllers, sensor fusion, vehicle dynamics, and 3D visualization components.

As of Release 2020b, you can incorporate deep learning networks into your Simulink models to perform system-level simulation and deployment.

Learn how to run simulations of a lane and vehicle detector using deep learning networks based on YOLO v2 in Simulink on NVIDIA® GPUs. The Simulink model includes preprocessing and postprocessing components that perform operations such as resizing incoming videos, detecting coordinates, and drawing bounding boxes around detected vehicles. With the same Simulink model, you can generate optimized CUDA code using cuDNN or TensorRT to target GPUs such as NVIDIA Tesla® and NVIDIA Jetson® platforms.

Simulink is a trusted tool for designing complex systems that include decision logic, and controllers, sensor fusion, vehicle dynamics, and 3D visualization components. As of release 2020b, you can incorporate deep learning networks into your Simulink models to perform system-level simulation and deployment. If we look inside the vehicle and lane detection subsystem, we'll see the use of two deep learning networks at the top and bottom. Our input video will come in, we'll then do some preprocessing to resize the image, which we then feed into our lane detection network.

Here, you can see this is being brought in by a math file our MATLAB directory. We'll do some post-processing to detect the coordinates of the left number right lanes, and finally we'll do some annotation to highlight the vehicle and lanes. The bottom Deep Learning network is detecting vehicles, and it's based off of YOLOv2. And again, you can see this is being loaded off of the mat file on our directory. So coming back, we can run simulation. You see our input video on the left, and our output video on the right where we're highlighting the left and right lanes with the green markers. And then we're driving yellow bounding boxes around vehicles that we do see. So at this point, we're ready to go ahead and generate code so we can launch either the Simulink coder or embedded code wraps.

Let's take a look at the Code Generation settings first. Here, you'll see we're using the correct system target file, and we've checked the checkbox here to generate CUDA code. We can also take a look at the deep learning libraries. In this case, we can choose either cuDNN or TensorRT so we'll keep cuDNN for now. And for Toolchain settings, we're using NVIDIA's CUDA toolkit. And finally, for non-deep learning parts, we're using optimized libraries like cuBLAS, cuSOLVER, and cuFFT.

So we're all set, let's go ahead and generate code. Here's the Code Generation Report, and you can see the files generated on the left. Let's first look for the step function. Down here, you can see the cudaMalloc calls which is allocating variables on the GPU memory. Here, we have cudaMemcpy's which is copying data from the CPU memory to the GPU memory and back at the right places. And here, are a couple of GPU kernels being launched in order to speed things up on the GPU cores. We have our two deep learning networks as well. Here's our first one, LaneNet. And you can see all the public and private methods here. Here we have setup, predict, cleanup, in addition to several others.

Here's our second Deep Learning network, that's the vehicle detector using YOLOv2. And again, we have the same set of methods. If we look inside of the setup method, you can see the code which is run once at the beginning of the program to load the deep learning network into memory. So if you look inside of here, we are going through one layer at a time, and we're loading the weights and biases as we go through. So that's a quick look at generating CUDA code from Simulink models that use deep learning networks. For more information, take a look at the links below.

Related Products

  • Reinforcement Learning Toolbox
  • Deep Learning Toolbox
  • Simscape Multibody

Learn More

Code Generation for a Deep Learning Simulink Model that Performs Lane and Vehicle Detection

Feedback

Featured Product

Reinforcement Learning Toolbox

  • Request Trial
  • Get Pricing

Up Next:

8:58
MATLAB and Simulink Racing Lounge: CAD Import in...

Related Videos:

34:03
Determining Mechanical Loads for Wind Turbines
24:56
Optimal Neural Network for Automotive Product Development
2:57
Generate Executable for Prototyping Using MATLAB Coder
1:07:31
Generate C Code from MATLAB Functions Using the Embedded...

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • 联系销售
  • 试用软件

了解产品

  • MATLAB
  • Simulink
  • 学生版软件
  • 硬件支持
  • 文件交换

试用或购买

  • 下载
  • 试用软件
  • 联系销售
  • 定价和许可
  • 如何购买

如何使用

  • 文档
  • 教程
  • 示例
  • 视频与网上研讨会
  • 培训

获取支持

  • 安装帮助
  • MATLAB 问答社区
  • 咨询
  • 许可中心
  • 联系支持

关于 MathWorks

  • 招聘
  • 新闻室
  • 社会愿景
  • 联系销售
  • 关于 MathWorks

MathWorks

Accelerating the pace of engineering and science

MathWorks 公司是世界领先的为工程师和科学家提供数学计算软件的开发商。

发现…

  • Select a Web Site United States
  • 专利
  • 商标
  • 隐私权政策
  • 防盗版
  • 应用状态

京ICP备12052471号

© 1994-2021 The MathWorks, Inc.

  • Weibo
  • WeChat

    WeChat

  • Bilibili
  • Youku
  • Facebook
  • Twitter
  • LinkedIn
  • RSS

关注我们