# CUDA computing with Matlab

**URL:** <https://forums.developer.nvidia.com/t/cuda-computing-with-matlab/26302>\
**Category:** CUDA Programming and Performance\
**Created:** [April 10, 2012, 3:04pm UTC](https://forums.developer.nvidia.com/t/cuda-computing-with-matlab/26302 "2012-04-10T15:04:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasin](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Yasin](https://forums.developer.nvidia.com/u/Yasin)\
**Post date:** [April 10, 2012, 3:04pm UTC](https://forums.developer.nvidia.com/t/cuda-computing-with-matlab/26302/1 "2012-04-10T15:04:57Z")

</div>

Hello everyone,  
I would like to use the Matlab CUDA plug-in to compile my CU file in Matlab. The operating system is Ubuntu 10.10 and the Matlab version is 2011a. When I finish programming the cu file and compile it in Matlab, it encounter the following problem:

nvmex -f nvmexopts64.bat my.cu \home\lys\cuda\include \home\lys\cuda\lib\x64 -lcudart -lcufft  
.: 1341: nvmexopts64.bat: not found

What should I do next ? I do put the nvmex.m nvmex\_help.m and nvmexopts64.bat into the same folder of the my.cu file.

Thanks a lot

---

<div class="post-metadata">

**Author:** ![melonakos](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/melonakos/32/10034_2.png) [@melonakos](https://forums.developer.nvidia.com/u/melonakos)\
**Post date:** [April 10, 2012, 3:08pm UTC](https://forums.developer.nvidia.com/t/cuda-computing-with-matlab/26302/2 "2012-04-10T15:08:35Z")

</div>

You may have to hack at the various scripts to force them to be able to locate the .bat file properly. Those scripts are really old and not really maintained very well.

Of course, you always have the option to get better integration of your CUDA code into MATLAB(R) through the Jacket SDK, which [has many advantages](http://blog.accelereyes.com/blog/2010/10/29/jacket_sdk_trumps_mex/) over using nvmex. Good luck!

---

<div class="post-metadata">

**Author:** ![mfatica](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mfatica](https://forums.developer.nvidia.com/u/mfatica)\
**Post date:** [April 10, 2012, 3:13pm UTC](https://forums.developer.nvidia.com/t/cuda-computing-with-matlab/26302/3 "2012-04-10T15:13:38Z")

</div>

There is another way of building mex files with CUDA support.

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

---

<div class="post-metadata">

**Author:** ![Yasin](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Yasin](https://forums.developer.nvidia.com/u/Yasin)\
**Post date:** [April 10, 2012, 3:30pm UTC](https://forums.developer.nvidia.com/t/cuda-computing-with-matlab/26302/4 "2012-04-10T15:30:25Z")

</div>

> [@](#):
>
> There is another way of building mex files with CUDA support.
> 
> 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

Thanks for your help. When I use the commend !nvcc -c my.cu -Xcompiler -fPIC -I /usr/local/matlab/extern/include in my Matlab commend window, it encounters:

/bin/bash: nvcc: command not found

---

<div class="post-metadata">

**Author:** ![mfatica](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mfatica](https://forums.developer.nvidia.com/u/mfatica)\
**Post date:** [April 10, 2012, 3:51pm UTC](https://forums.developer.nvidia.com/t/cuda-computing-with-matlab/26302/5 "2012-04-10T15:51:35Z")

</div>

Use the full path /usr/local/cuda/bin/nvcc or fix you .bashrc
