gpucoder.sort()takes advantage of the Thrust Library for generating kernels on the GPU. Certain Thrust APIs take advantage of the dynamic parallelism feature of CUDA. Compiling CUDA code that contains dynamic parallelism on NVIDIA embedded boards may result in a linker error because of unrecognizable symbols, similar to the one above.
There are two possible scenarios where enabling debug mode can cause the nvlink errors:
- A MATLAB entry-point function or a Simulink MATLAB Function block directly calls gpucoder.sort
- A built-in function calls gpucoder.sort. For example, a deep learning object detector such as yolov2ObjectDetector
The issue is also observed when these models use the XCP-based External Mode functionality. Because External Mode relies on the presence of debug symbols to access both signals and parameters variables for calibration and measurement (in accordance to the ASAM MCD-1-XCP communication protocol), the debug mode is automatically enabled even if the parameter is not explicitly set.
To fix these linker error(s), it is recommended to provide the linker with the compute capability of the board. For GPU Coder, you must set the compute capability of the GPU device on the board through the code configuration object or Simulink configuration parameters.
Identify the Compute Capability of the Target Platform
To get the compute capability of the board, create a live hardware connection to the board as follows:
hwobj = jetson('<IpAddress>','<userName>','<passWord>'); % For NVIDIA Jetson
hwobj = drive('<IpAddress>','<userName>','<passWord>'); % For NVIDIA Drive
Get the compute capability of the board as follows:
computeCapability = num2str(hwobj.GPUInfo.ComputeCapability); % For NVIDIA Jetson
computeCapability = num2str(hwobj.GPUInfo(<GPU ID>).ComputeCapability); % For NVIDIA Drive
To set the compute capability of the model to that of the board programmatically, enter the following command in the MATLAB Command Window:
For GPU code generation from MATLAB, set the compute capability in the code configuration object.
cfg.GpuConfig.ComputeCapability = computeCapability; % GPU Config object