I encounter the same error when targeting NVIDIA Jetson & DRIVE with debugging enabled.
In Simulink:
I have a Simulink model that I’m trying to deploy to an NVIDIA Jetson board. The model contains a MATLAB Function block to perform sort on the GPU using the gpucoder.sort function.
[~,<indexOutput>] = gpucoder.sort(<input>)
The model is configured to generate GPU code and deploy to the NVIDIA Jetson/Drive hardware. In addition, I have set the Debug mode parameter in the Code Generation > Build Configuration pane. When I build the model, the generated code fails to link on the target during the compilation phase with a nvlink error. A snippet of the error is shown below:
nvlink error : Undefined reference to 'cudaDeviceSynchronize' in '<Model>.o' nvlink error : Undefined reference to 'cudaPeekAtLastError' in '<Model>.o' nvlink error : Undefined reference to 'cudaGetParameterBuffer' in '<Model>.o' nvlink error : Undefined reference to 'cudaLaunchDevice' in '<Model>.o' nvlink error : Undefined reference to 'cudaGetErrorString' in '<Model>.o'
I have been successful deploying other models using the same configuration. But this combination of gpucoder.sort and debug mode fails with the aforementioned error.
In MATLAB:
Instead of using Simulink, I created an entry-point function in MATLAB with a similar code signature and attempted GPU code generation by using a code configuration object set for Jetson/Drive targeting.
cfg = coder.gpuConfig('exe');cfg.Hardware = coder.hardware('NVIDIA Jetson'); % For NVIDIA Jetson
cfg.GenerateExampleMain = 'GenerateCodeAndCompile';cfg.BuildConfiguration = 'Debug';codegen -config cfg -args {<required arguments>} <function> -report
I encounter the same error as before.
nvlink error : Undefined reference to 'cudaDeviceSynchronize' in '<function>.o' nvlink error : Undefined reference to 'cudaPeekAtLastError' in '<function>.o' nvlink error : Undefined reference to 'cudaGetParameterBuffer' in '<function>.o' nvlink error : Undefined reference to 'cudaLaunchDevice' in '<function>.o' nvlink error : Undefined reference to 'cudaGetErrorString' in '<function>.o'
Are there additional options that need to be enabled? How can I resolve this?
Best Answer