I try to compile the GPUCoder example within 2018a in ubuntu 16.04. But the compilation failed within matlab with following output:
>> codegen -config cfg -args {ones(227,227,3,'single'), coder.Constant('alexnet.mat')} alexnet_predict.m
------------------------------------------------------------------------
nvcc -ccbin /bin/aarch64-linux-gnu-g++ -rdc=true -Xcompiler -fPIC -I/include -Xcudafe "--diag_suppress=unsigned_compare_with_zero" -c -Xcompiler -MMD,-MP -O2 -arch sm_35 -DMODEL=alexnet_predict -DHAVESTDIO -DUSE_RTMODEL -DUNIX -I/home/ibmfuchs/gpucoderdemo_jetson_tx22/codegen/lib/alexnet_predict -I/home/ibmfuchs/gpucoderdemo_jetson_tx22 -I/home/ibmfuchs/Programs/Matlab/2018a/extern/include -I/home/ibmfuchs/Programs/Matlab/2018a/simulink/include -I/home/ibmfuchs/Programs/Matlab/2018a/rtw/c/src -I/home/ibmfuchs/Programs/Matlab/2018a/rtw/c/src/ext_mode/common -I/home/ibmfuchs/Programs/Matlab/2018a/rtw/c/ert -Iinclude -o cnn_api.o cnn_api.cpp
/bin/sh: 1: nvcc: not found
gmake: *** [cnn_api.o] Error 127
Error(s) encountered while building "alexnet_predict":
### Failed to generate all binary outputs.
------------------------------------------------------------------------
??? Build error: C++ compiler produced errors. See the Build Log for further details.
Code generation failed: View Error Report
Error using codegen
calling nvcc from workspace I got:
>> system('nvcc')
/bin/bash: nvcc: command not found
ans =
127
But in terminal I have no problem to call nvcc:
ibmfuchs@SUbuntu:/$ nvcc
nvcc fatal : No input files specified; use option --help for more information
Can anyone please help? Thanks

 Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Abr. de 2018

0 votos

nvcc is not on your PATH environment variable when you are in MATLAB. When you start MATLAB by way of icon, it does not go through login and so your shell configuration files are not executed to do any customization of environment variables for you.
You should use setenv() within MATLAB to add the directory that nvcc is in to PATH, or else you should alter your system PATH environment variable to include the proper directory, or else you should put a symbolic link from one of the directories that is on the system default PATH to the actual location of nvcc
Example:
p = getenv('PATH');
setenv('PATH', [p ':/usr/local/bin'])

11 comentarios

Song Decn
Song Decn el 14 de Abr. de 2018
thanks. it works. but I get another error:
codegen -config cfg -args {ones(227,227,3,'single'), coder.Constant('alexnet.mat')} alexnet_predict.m
------------------------------------------------------------------------
nvcc -ccbin /bin/aarch64-linux-gnu-g++ -rdc=true -Xcompiler -fPIC -I/include -Xcudafe "--diag_suppress=unsigned_compare_with_zero" -c -Xcompiler -MMD,-MP -O2 -arch sm_35 -DMODEL=alexnet_predict -DHAVESTDIO -DUSE_RTMODEL -DUNIX -I/home/ibmfuchs/gpucoderdemo_jetson_tx22/codegen/lib/alexnet_predict -I/home/ibmfuchs/gpucoderdemo_jetson_tx22 -I/home/ibmfuchs/Programs/Matlab/2018a/extern/include -I/home/ibmfuchs/Programs/Matlab/2018a/simulink/include -I/home/ibmfuchs/Programs/Matlab/2018a/rtw/c/src -I/home/ibmfuchs/Programs/Matlab/2018a/rtw/c/src/ext_mode/common -I/home/ibmfuchs/Programs/Matlab/2018a/rtw/c/ert -Iinclude -o cnn_api.o cnn_api.cpp
/bin/aarch64-linux-gnu-g++: No such file or directory
gmake: *** [cnn_api.o] Error 1
Error(s) encountered while building "alexnet_predict":
### Failed to generate all binary outputs.
------------------------------------------------------------------------
??? Build error: C++ compiler produced errors. See the Build Log for further details.
Song Decn
Song Decn el 14 de Abr. de 2018
btw, I've installed aarch64-linux-gnu-g++ properly
Song Decn
Song Decn el 14 de Abr. de 2018
it turns out that on my machine aarch64-linux-gnu-g++ is installed under: /usr/bin instead of /bin.
Do you know how to fix this?
Walter Roberson
Walter Roberson el 14 de Abr. de 2018
After -ccbin you have to name either the directory your compiler is in, or else the full path to your compiler including executable name. It appears that your compiler is not in the location you named.
Song Decn
Song Decn el 14 de Abr. de 2018
Hi Walter, thanks for your help. I used whole day and managed finally to compile the GPU Tx2 example in Matlab. Now all the files can be compiled and I get an excutable alextnet_exe. But after I try to run it via "./alexnet_exe 1", I get an error "Permission denied"
Is or was there something wrong?
Thnks
Walter Roberson
Walter Roberson el 14 de Abr. de 2018
chmod +x ./alexnet_exe
Song Decn
Song Decn el 15 de Abr. de 2018
Thank Walter. Again I am step further, now I get another error
nvidia@tegra-ubuntu:~/Documents/Work/alexnet_predict$ ./alexnet_exe 1
Could not open the video capture device.
How can i find out the device number for my camera?
Song Decn
Song Decn el 15 de Abr. de 2018
i tried all the commands from your referenced site but i cant figure out. also the on board camera is working fine. :(
Walter Roberson
Walter Roberson el 15 de Abr. de 2018
Hannah Nithilla
Hannah Nithilla el 16 de Oct. de 2019
how exactly did you use this solution in your code?
p = getenv('PATH');
setenv('PATH', [p ':/usr/local/bin'])
because i still get nvcc not found.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Abr. de 2018

Comentada:

el 16 de Oct. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by