Problems with CUDA and MATLAB 7.9


When compiling some of the Nvidia plugin examples (and some mine) for Matlab Toolkit 1.1, using Matlab 7.9 (R2009b) I obtain the following error:

mex: /opt/matlabR2009b/extern/src/mexversion.c not a normal file or does not exist.

I read several posts in MATLAB newsgroup forum that the problem could be because using an incorrect (older) version of mex. This is not the case, because my machine is a recently installed machine.

Also, I read a similar problem than mine here, in Nvidia forums:…st=#entry968666

Is the same problem?

How can I solve it?

Is Nvidia going to release a new version of the MATLAB plugin?

By the way. My machine is a PC with a Nvidia GTX280 and

Ubuntu 9.1 Linux 64 bit
Matlab R2009b 64 bit
CUDA 2.3

Thank you


Just wanted to point you to Jacket ( ) that does all the groundwork stuff for you so you don’t have to hassle with this stuff. Jacket is a runtime that does a ton of optimizations for you that no other method will give you, for info about what a runtime is see this link: And if you have custom CUDA code you need to get into MATLAB, you’re better off using the Jacket SDK ( ).

Of course the downside is that Jacket is not free. But we just cut prices in half, so that may help! We’re happy to help and would love to figure out how to get you to use Jacket… shoot me a PM to discuss if you’d like :)

Two other Matlab CUDA plug-ins (that are free) are GPUmat and GPULib.

The newer versions of matlab (since 2009a I believe) do not use mexversion.c dependency anymore.
mfatica helped me out with this:

Try compiling the file inside matlab:
!nvcc -c -Xcompiler -fPIC -I/usr/local/matlab/extern/include

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


Yes, you are right, but as far as I know, they don’t integrate yet solving linear system (altough) I know that this was done in future.

Yes. In fact, I pointed to your post before. I will use your solution.

Thank you very much




Hi again:

It worked changing the commands a little bit. My machine is linux 64 bit

!nvcc -c -Xcompiler -fPIC - I/usr/local/cuda/include -I/usr/local/soft/matlabR2009b/extern/include

mex sgemm_cu.o -cxx -L/usr/local/cuda/lib64 -lcufft -lcudart -lcublas

In mex, I needed to use the -cxx option, because as far as I know, the .cu files are c++ (cxx) files

Also I needed to change some lines (1 or 2) in .cu, because C/C++ prototypes (header files in mex) are more restrictive
than using the NVIDIA Makefile. I don’t know exactly why.

Does anybody know if NVIDIA is going to make new Makefiles…compatibles with R2009b?


You’re right. The free ones don’t include that. Jacket does have linear system solving capabilities with JacketDLA (a part of Jacket 1.3 which is currently available as a beta and will go to public release next week) which includes mldivide, svd, inv, eig, et al. Enjoy!