Matlab and ROS---Deep Learning (9)

0. Introduction

After understanding the content of the above 8 lectures, basically the most critical parts of ROS and Matlab have been introduced. In our last lecture, we will briefly talk about how to combine ROS in Matlab to complete the identification and detection of obstacles.

1. Using CUDA in Matlab

Configuring SimulinkCoder to generate and build CUDA ROS nodes from Simulink models is what we need to talk about in this section. In order to complete the configuration of the model and generate CUDA code containing ROS nodes. Then deploy the CUDA ROS node to a local or remote device target.

First, you need to verify that your development computer has the drivers, tools, libraries, and configurations required for GPU code generation. Here we enter the following command in the MATLAB command window:

gpuEnvObj = coder.gpuEnvConfig;
gpuEnvObj.BasicCodegen = 1;
gpuEnvObj.BasicCodeexec = 1;
gpuEnvObj.DeepLibTarget = "tensorrt";
gpuEnvObj.DeepCodeexec = 1;
gpuEnvObj.DeepCodegen = 1;
results = coder.checkGpuInstall(gpuEnvObj)

Below we can see similar output, namely

Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN Environment : PASSED
TensorRT Environment : PASSED
Basic Code Generation : PASSED
Basic Code Execution : PASSED
Deep Learning (TensorRT) Code Generation: PASSED
Deep Learning (TensorRT) Code Execution: PASSED
results =
struct with fields:
gpu: 1
cuda: 1
cudnn: 1
tensorrt: 1
basiccodegen: 1
basiccodeexec: 1
deepcodegen: 1
deepcodeexec: 1
tensorrtdatatype: 1
profiling: 0

Then use Simulink to complete the simulation model and GPU code generation, which is divided into the following steps:

  1. Open the Simulink model to be configured for GPU code generation.

  2. First select the Simulation option, in the Prepare section, expand the gallery, and under Configuration & Simulation, select Model Settings.

  3. In the left pane of the Configuration Parameters dialog box, select the Hardware Implementation node. Hardware Board selects Robot Operating System (ROS), and specifies the Device Vendor and Device Type of the hardware. Expand Device Details and verify that Support long long is selected.
    insert image description here

  4. In the Simulation Target node, select GPU acceleration. If your model has a deep learning block, then, under Deep Learning, select the appropriate Target library.
    insert image description here
    Select the Code Generation node. Select Language as "c++" in Target selection, and select Generate GPU code.
    insert image description here
    If the model has deep learning blocks, expand the Code Generation node and select the Interface node. Then, select an appropriate value for Target library in Deep Learning.
    insert image description here
    Select the GPU Code node, enable acceleration modules such as cuBLAS, cuSOLVER, and cuFFT under Libraries,
    insert image description here
    and then follow the configuration in Matlab and ROS (1/2)—Simulink (2) to output the C++ code.

2. Deep learning and ROS follower robot

…For details, please refer to Gu Yueju

Guess you like

Origin blog.csdn.net/lovely_yoshino/article/details/128308365