Make the matlab_cuda example ERROR

Hi guys, when I finished install the Matlab and CUDA in my Ubuntu, I try to make the examples from cu file to mexa64 file. However, when I use the unix(‘make’). it returns the following error information.

unix(‘make’);
/home/lys/MATLAB/R2011a/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ fft2_cuda.c
-I/home/lys/cuda/include -L/home/lys/cuda/lib -lcufft -Wl,-rpath,/home/lys/cuda/lib
/usr/bin/ld: skipping incompatible /home/lys/cuda/lib/libcufft.so when searching for -lcufft
/usr/bin/ld: cannot find -lcufft
collect2: ld returned 1 exit status

mex: link of ' "fft2_cuda.mexa64"' failed.

make: *** [fft2_cuda.mexa64] Error 1

Do you know how to solve the problem and would you please help me out ? Thank yo so much

Change -L/home/lys/cuda/lib to -L/home/lys/cuda/lib64

Thanks so much. This problem is solved. However, even though I have already install the Nvidia_GPU_Computing_SDK and also make it successfully. When I try to make the Matlab examples, it still report the following errors:

unix(‘make’)
/home/lys/MATLAB/R2011a/bin/mex CFLAGS=’-fPIC -D_GNU_SOURCE -pthread -fexceptions’ COPTIMFLAGS=’-O3 -funroll-loops -msse2’ fft2_cuda.c
-I/home/lys/cuda/include -L/home/lys/cuda/lib64 -lcufft -Wl,-rpath,/home/lys/cuda/lib64
fft2_cuda.o: In function mexFunction': fft2_cuda.c:(.text+0xddf): undefined reference to cudaMalloc’
fft2_cuda.c:(.text+0xdf4): undefined reference to cudaMemcpy' fft2_cuda.c:(.text+0xe3c): undefined reference to cudaMemcpy’
fft2_cuda.c:(.text+0xe91): undefined reference to `cudaFree’
collect2: ld returned 1 exit status

mex: link of ' "fft2_cuda.mexa64"' failed.

make: *** [fft2_cuda.mexa64] Error 1

It seems that I did not install the Matlab CUDA interface successfully. Can you help me to solve the problem ?
Thanks

Add -lcudart

Thank you so much !!!

This problem is solved. However, when I try to make the Matlab examples, it still report the following errors:

unix(‘make’)
./nvmex -f nvopts.sh Szeta.cu -I/home/lys/cuda/include -L/home/lys/cuda/lib64 -lcufft -lcudart -Wl,-rpath,/home/lys/cuda/lib64
.: 1412: nvopts.sh: not found
make: *** [Szeta.mexa64] Error 2

It seems that I did not install the Matlab CUDA interface successfully. Can you help me to solve the problem ?
Thanks

Try this other method.

From inside Matlab:

!nvcc -c myfun.cu -Xcompiler -fPIC -I /usr/local/matlab/extern/include

mex myfun.o -L /usr/local/cuda/lib64 -lcudart -lcufft

Hi mfatica,

!nvcc -c Szeta.cu -Xcompiler -fPIC -I /home/lys/MATLAB/R2011a/extern/include
/bin/bash: nvcc: command not found

It seems that I should change to bash model . But I do not know how…

I think you didn’t add $(CUDA_INSTALL_DIR)/bin to PATH

$ export PATH=$PATH:/usr/local/cuda/bin # This should fix your issue.

Also, You can use Jacket SDK for compiling custom CUDA code for Matlab. Visit this for more on Jacket SDK and how to use it with Matlab. Jacket ships some pretty good SDK samples and is very easy to setup and get started with.