To use GPU Coder™ for CUDA® C/C++ code generation, you must install the following products:
MATLAB Coder™ (required).
Parallel Computing Toolbox™ (required).
Simulink® (required for generating code from Simulink models).
Computer Vision Toolbox™ (recommended).
Deep Learning Toolbox™ (required for deep learning).
Embedded Coder® (recommended).
Image Processing Toolbox™ (recommended).
Simulink Coder (required for generating code from Simulink models).
GPU Coder Interface for Deep Learning Libraries support package (required for deep learning).
GPU Coder Support Package for NVIDIA® GPUs (required for deployment to embedded targets such as NVIDIA Jetson and Drive).
For instructions on installing MathWorks® products, see the MATLAB installation documentation for your platform. If you have installed
MATLAB and want to check which other MathWorks products are installed, enter
ver in the MATLAB Command Window. To install the support packages, use Add-On Explorer in
If MATLAB is installed on a path that contains non 7-bit ASCII characters, such as Japanese characters, GPU Coder does not work because it cannot locate code generation library functions.
NVIDIA GPU enabled for CUDA with compute capability 3.2 or higher and a compatible graphics driver. For more information, see CUDA GPUs (NVIDIA).
Deep learning applications in 8-bit integer precision requires a CUDA GPU with a compute capability of 6.1, 6.3 or higher. For half-precision (16-bit integer), a CUDA GPU with minimum compute capability of 7.0 is required.
ARM® Mali graphics processor.
For the Mali device, GPU Coder supports C++ code generation for only deep learning networks.
GCC C/C++ compiler 6.3.x
Microsoft® Visual Studio® 2013
Microsoft Visual Studio 2015
Microsoft Visual Studio 2017
Microsoft Visual Studio 2019
Standalone code (static library, dynamically linked library, or executable program) generation has additional software requirements. For CUDA MEX, the code generator uses the NVIDIA compiler and libraries installed with MATLAB.
GPU Coder has been tested with CUDA toolkit v9.x-v10.2.
To download the CUDA toolkit, see CUDA Toolkit Archive (NVIDIA).
It is recommended to select the default
installation options that includes
NVIDIA CUDA deep neural network library (cuDNN) for NVIDIA GPUs
cuDNN is a GPU-accelerated library of primitives for deep neural networks. For more information, see cuDNN (NVIDIA).
GPU Coder has been tested with cuDNN v7.5.x.
TensorRT is a high performance inference optimizer and runtime library for NVIDIA GPUs. For more information, see TensorRT (NVIDIA).
GPU Coder has been tested with TensorRT v7.0.x.
ARM Compute Library
The ARM Compute Library is a optimized computer vision and machine learning library for Mali GPUs. For more information, see Compute Library (ARM).
GPU Coder has been tested with v19.05.
This library must be installed on the ARM target hardware. Do not use a prebuilt library because it might be incompatible with the compiler on the ARM hardware. Instead, build the library from the source code. Build the library on either your host machine or directly on the target hardware. See instructions for building the library on GitHub®. You can also find information on building the library for CPUs in this post on MATLAB answers.
When building the Compute Library,
enable OpenCL support in the build options. See the ARM
Library documentation for instructions. OpenCL library (v1.2 or higher)
on the ARM target hardware. See the ARM Compute Library documentation for version requirements. After the
build is complete, rename the
Open Source Computer Vision Library (OpenCV)
Required for deep learning examples. For more information, see OpenCV.
For examples targeting NVIDIA GPUs on the host development computer, use OpenCV v3.1.0. For examples targeting ARM GPUs, use OpenCV v2.4.9 on the ARM target hardware.
The examples require separate libs
On Windows, a space or special character in the path to the tools, compilers, and libraries can create issues during the build process. You must install third-party software in locations that does not contain spaces or change Windows settings to enable creation of short names for files, folders, and paths. For more information, see Using Windows short names solution in MATLAB Answers.
The Analyze Execution Profiles of the Generated Code workflow depends
nvprof tool from NVIDIA. From CUDA toolkit v10.1 onwards, NVIDIA restricts access to performance counters to only admin users. To enable
GPU performance counters to be used by all users, see the instructions provided in
GPU Coder does not support generating CUDA code by using CUDA toolkit version 8.
Other versions of these deep learning libraries may have compatibility issues with all the features GPU Coder supports this release.
On the target platforms, use the JetPack or the DriveInstall software appropriate for your board to install all the libraries. For more information, see Install and Setup Prerequisites for NVIDIA Boards (GPU Coder Support Package for NVIDIA GPUs).