custom LAPACK callback issue when deploying to Nvidia Jetson Nano.
4 次查看(过去 30 天)
显示 更早的评论
Good evening to everyone and thanks in advance for your kind help.
I am designing a computer vision algorithm for an aerospace application (Sense and avoid system for a UAV), which performs object detection and tracking. The algorithms has to be deployed on Nvidia Jetson embedded platforms. For ease of deployment (since I am an aersopace engineer and i am not too comfortable with C++) the algorithm has been developed as a Simulink model becuase this entails several advantages when it comes to deployment (everything is automated and very intuitive).
Since the algorithm performs some heavy-duty convolution operations in the stage of object detection, it is mandatory to use CUDA in order to better harness the computational power of Nnvidia Jetson platforms. On my laptop running windows 10 featuring Nvidia gtx 1650 dedicated graphic card, the algorithm works flawlessly and the difference in performance when toggling the option in Simulation Target --> GPU acceleration is blatantly evident.
The issue arises when i am trying to deploy the algorithm on the Jetson Nano. I cannot upload here on the forum the file of the entire simulink system due to privacy but I will upload a simplfied example where the problem resides. Essentially it's just a visual tracker using KLT feature tracker and RANSAC for outliers rejection. If compiled and deployed without checking the option "Generate GPU code" in configuration parameters ---> Code Generation, everyting works as expected and on the screen connected to the Jetson nano I can see the live stream with corner points overlayed and coorectly tracked across different frames. However if i toggle that option, thus enabling GPU cuda code generation, when i launch the elf executable on the target it does nothing and it crashes. I am sure that the problem lies in the fact that the function "estimateGeometricTransform" leverages Singular Value Decomposition (SVD) and "Cusolver" is not entirely compatible with this. Indeed i can read this message on the Diagnostic Viewer during the build:
'This mode of the 'svd' function is not fully supported by the NVIDIA cuSOLVER library. To generate code that uses the LAPACK library in addition to the cuSOLVER library, consider providing a LAPACK callback class'.
Now, I have tried to provdie a LAPACK callback class without success so far becuase the build procedure exits with errors. This is an example of what i have tried so far.
classdef customLAPACK < coder.LAPACKCallback
methods (Static)
function hn = getHeaderFilename()
% hn = 'lapack.h';
% hn = 'clapacke.h';
hn = 'opencv_lapack.h';
end
function updateBuildInfo(buildInfo,buildctx)
buildInfo.addIncludePaths('/usr/local/src/opencv-4.2.0/build',...
'usr/include','/usr/include/aarch64-linux-gnu');
buildInfo.addCompileFlags('`pkg-config --cflags lapack opencv4`');
buildInfo.addLinkFlags('`pkg-config --libs lapack opencv4`');
end
end
end
It is worth mentioning that on the Jetson Nano I have compiled opencv verions 4.2.0 from source with CUDA, gstreamer, CUDNN and CUBLAS enabled. Could be useful also to inlcude the result of the following commands (run in a shell on the target):
pkg-config --list-all |grep lapack:
lapack-openblas openblas-lapack - Optimized BLAS (linear algebra) library, LAPACK
lapack-netlib LAPACK - FORTRAN reference implementation of LAPACK Linear Algebra PACKage
lapack openblas-lapack - Optimized BLAS (linear algebra) library, LAPACK
lapack-atlas atlas-lapack - Automatically Tuned Linear Algebra Software, LAPACK
lapacke LAPACKE - C Standard Interface to LAPACK Linear Algebra PACKage
find /usr -type f -iname "*lapack*.h":
/usr/include/aarch64-linux-gnu/clapack.h
/usr/include/lapacke.h
/usr/include/lapacke_utils.h
/usr/include/openblas/lapacke.h
/usr/include/openblas/lapacke_utils.h
/usr/include/openblas/lapacke_mangling.h
/usr/include/openblas/lapacke_config.h
/usr/include/lapacke_mangling.h
/usr/include/eigen3/Eigen/src/QR/HouseholderQR_LAPACKE.h
/usr/include/eigen3/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h
/usr/include/eigen3/Eigen/src/Cholesky/LLT_LAPACKE.h
/usr/include/eigen3/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h
/usr/include/eigen3/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h
/usr/include/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h
/usr/include/eigen3/Eigen/src/misc/lapacke.h
/usr/include/eigen3/Eigen/src/misc/lapack.h
/usr/include/eigen3/Eigen/src/misc/lapacke_mangling.h
/usr/include/eigen3/Eigen/src/SVD/JacobiSVD_LAPACKE.h
/usr/include/eigen3/Eigen/src/LU/PartialPivLU_LAPACKE.h
/usr/include/lapacke_config.h
/usr/local/src/opencv-4.2.0/build/opencv_lapack.h
/usr/local/src/opencv-3.4.0/build/opencv_lapack.h
Any help is kindly appreciated. Let me know if you require additional information.
Marco.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with GPU Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!