imread Nvidia Jetson Nano not working
Show older comments
i'm trying to get my Jetson Nano to work with the MATLAB Coder Support Package for NVIDIA Jetson Package.
I installed all the prerequisites and succesfully connected with the Jetson Nano. I put an JPG-image(with putFile) into a folder and wrote following function:
function showPics(string1)
img1 = (imread(string1));
d = imageDisplay(hwJetson);
image(d,img1);
end
then i tried to compile that and build it on the jetson with these commands:
cfg = coder.config('exe');
cfg.TargetLang = 'C++';
cfg.Hardware = coder.hardware('NVIDIA Jetson');
cfg.Hardware.BuildDir = '~/Matlabtest';
cfg.CustomSource = fullfile('main.cpp');
codegen('-config',"cfg","showPics","-args",{"~/Matlabtest/left1.jpg"});
all i'm getting is the following error:
??? The function imread uses a precompiled shared library which is not supported on
the chosen target.
i took a look on the documentation (https://de.mathworks.com/help/matlab/ref/imread.html?searchHighlight=imread&s_tid=srchtitle_imread_1) and it says:
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
- Supports reading of 8-bit JPEG images only. The input argument filename must be a valid absolute path or relative path.
- This function generates code that uses a precompiled, platform-specific shared library (Image Processing Toolbox).
there it must be possible to use imread with the Jetson... can't find anything on google. The application will use the attached webcams, but for now it's easier to develop with images already taken.
i tried the coder.CheckGpuInstall command, which passes all test. i get the following result:
Compatible GPU : PASSED (Warning: Support for GPU devices with Compute Capability 5.2 will be removed in a future MATLAB release. For more information on GPU support, see GPU Support by Release.)
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN
Environment : PASSED (Warning: Deep learning code generation has been tested with cuDNN v8.1. The provided cuDNN library v8.4 may not be fully compatible.)
Basic Code Generation : PASSED
Basic Code Execution : PASSED
ans =
struct with fields:
gpu: 1
cuda: 1
cudnn: 1
tensorrt: 0
basiccodegen: 1
basiccodeexec: 1
deepcodegen: 0
deepcodeexec: 0
tensorrtdatatype: 0
profiling: 0
I'm stuck for now and really appreciate all the help i can get :)
6 Comments
Nathan Malimban
on 27 Jun 2022
Hi Moritz,
You could use OpenCV to read the image on the Jetson. To integrate OpenCV with the code generation workflow, you would:
- Use coder.cinclude in your .m file to establish dependency on OpenCV headers.
- Use coder.ceval in your .m file to make calls to the OpenCV apis to read the image.
There is an example of such a workflow to generate code that reads an image on a raspberrypi:
If you open this example in MATLAB and go to the MATLAB function "raspi_fileRead_resnet.m" in the example directory, you will see a reference to a function called "readResizedImg". Open readResizedImg.m. This is an example you could follow of how lto make calls to OpenCV apis via coder.ceval.
Nathan
Moritz Schneider
on 29 Jun 2022
Nathan Malimban
on 29 Jun 2022
Hi Moritz,
The doc page for imread does indeed mention that it is supported for GPU codegen. But there are different types of codegen support. For imread GPU codegen, there is a note:
- This function generates code that uses a precompiled, platform-specific shared library (Image Processing Toolbox).
Functions that generate code that uses these precompiled libraries are only supported for codegen on platforms that can host MATLAB. So you could generate a MEX for a function using imread, but you wouldn't be able to generate standalone code for imread that you can deploy to your Jetson Nano. To do this, you'd need another option such as OpenCV.
Here is more info on the different types of codegen support:
Nathan
Moritz Schneider
on 30 Jun 2022
Edited: Moritz Schneider
on 30 Jun 2022
Moritz Schneider
on 30 Jun 2022
Ramakrishna Mandalapu
on 17 Jan 2023
Hi Moritz,
Did you manually run the application on the target? If not please run it manually, we will get to know if there are any compalints while running. You can also get the runtime log using the command shown in the above text
system(hwobj,'cat /home/flexybot/Matlabtest/MATLAB_ws/R2022a/C/Users/Moritz/Documents/Flexybot/Code/Matlab_Test/imreadOpenCV.log').
This will show if there are any issues while running the executable on the target.
Thanks,
Ramakrishna
Answers (0)
Categories
Find more on Get Started with GPU Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!