Hi,
I am working the project that requires me to call CUDA kernels from Matlab.
I am using Linux version 2.6.18-308.1.1.el5 and gcc version 4.1.2 20080704.
The matlab that I am running on my system is MATLAB Version: 7.14.0.739 (R2012a).
Now I have been searching on the net and every time I get the link for UCF which has the tutorial for Visual studio.
I need a comprehensive tutorial for linux installation of nvmex and its corresponding files.
(*** I guess nVIDIA has removed that link for matlab_with_cuda and the files as well ***)
I know about Jacket and Parallel Computing Toolbox but I still want go ahead with nvmex.
Please help me guys.
Just let me know if you have any sources for installation of nvmex tool for LINUX.
Thanks in advance.
Cheers
Instead of using nvmex, you can use these 2 lines from inside Matlab:
!nvcc -c my.cu -Xcompiler -fPIC -I /usr/local/matlab/extern/include
mex my.o -L /usr/local/cuda/lib64 -lcudart -lcufft
The rest of the code in whitepaper is still correct.
Hi,
Thanks a lot for your reply.
The first stage from your reply worked. I am using the sample code given in the white paper.
However for the second stage, I am getting the following error.
/*********************************************************/
>>mex sample.o -L /usr/local/cuda/lib64 -Icudart
Warning: No source files in argument list. Assuming C source
code for linking purposes. To override this
assumption use '-fortran' or '-cxx'.
Warning: You are using gcc version "4.1.2". The version
currently supported with MEX is "4.4.6".
For a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release/
sample.o: In function `__sti____cudaRegisterAll_41_tmpxft_00000955_00000000_4_sample_cpp1_ii_e53e6457()':
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x10): undefined reference to `__cudaRegisterFatBinary'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x76): undefined reference to `__cudaRegisterFunction'
sample.o: In function `__cudaUnregisterBinaryUtil()':
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x94): undefined reference to `__cudaUnregisterFatBinary'
sample.o: In function `__device_stub__Z15square_elementsPfS_i(float*, float*, int)':
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0xbc): undefined reference to `cudaSetupArgument'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0xd8): undefined reference to `cudaSetupArgument'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0xf4): undefined reference to `cudaSetupArgument'
sample.o: In function `mexFunction':
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x210): undefined reference to `cudaMalloc'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x230): undefined reference to `cudaMalloc'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x296): undefined reference to `cudaMemcpy'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x32b): undefined reference to `cudaMemcpy'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x3d7): undefined reference to `cudaConfigureCall'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x41a): undefined reference to `cudaMemcpy'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x493): undefined reference to `cudaFree'
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text+0x49c): undefined reference to `cudaFree'
sample.o: In function `cudaError cudaLaunch<char>(char*)':
tmpxft_00000955_00000000-1_sample.cudafe1.cpp:(.text._Z10cudaLaunchIcE9cudaErrorPT_[cudaError cudaLaunch<char>(char*)]+0x11): undefined reference to `cudaLaunch'
collect2: ld returned 1 exit status
mex: link of ' "sample.mexa64"' failed.
Error using mex (line 206)
Unable to complete successfully.
/***************************************************************************/
I even tried using the cufft library using the -I switch it was just giving me this output.
Is it possible that I am making mistakes somewhere or do I need to configure some stuff?
Kindly reply.
Thanks in advance.
Cheers
Hi,
isn’t it a “-l” (small L) rather than a “-I” (capital i) to be used in the command line? The former indicates to link with a library whereas the later indicates a path to search for include files.
So your command line as proposed by mfatica should read
mex my.o -L /usr/local/cuda/lib64 -lcudart -lcufft
and not
mex my.o -L /usr/local/cuda/lib64 -Icudart -Icufft
@Gilles_C
Thank you so much. I guess I made a mistake while reading the white paper instructions about the -I and -L switches.
Sample file is working fine and is producing the expected output.
@m.fatica
Thanks again.
Hello,
how to deal with the warnning of “No source files in argument list”, I am in trouble with this problem, and can not debug my program. I have added the flag of “-g”. thanks a lot!