MATLAB: How to get mexcuda running – compiler settings

cudaMATLAB Compilermexcuda

Dear Matlab community, I write to those of you that have already gone through the process of getting Matlab under Windows compiling CUDA .cu files with the command mexcuda. I try to run the command
mexcuda mexGPUExample.cu
but I get the following error:
Warning: The selected C++ compiler is not supported for CUDA compilation. Searching for a supported compiler.
> In mexcuda (line 89)
Error using mex
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2016a/win64.html.
Error in mexcuda (line 157)
[varargout{1:nargout}] = mex(mexArguments{:});
I have installed the CUDA 7.5 toolkit (which is the one that is shown as toolkitVersion when checking the gpuDevice command), and Microsoft Visual Studio 2015 (community edition).
I have tried to set the path to the compiler by entering
setenv('MW_NVCC_PATH','C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin')
but it didn't help. I also checked that Matlab uses the Microsoft Visual C++ compiler by checking
mex -setup
which returned
MEX configured to use 'Microsoft Visual C++ 2015 Professional (C)' for C language compilation.
Also, from the Windows command line, I can see that CUDA 7.5 is installed, by checking
nvcc --version
which returns
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:49:10_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17
I would appreciate any suggestions what else I can try. And: Does it make a difference that I have Visual Studio 2015 (instead of an older version)? It seems that there are no older versions of VS for download …

Best Answer

OK, it finally works. Indeed, it was necessary to remove MS Visual Studio 2015 and install MS Visual Studio 2013 (because CUDA 7.5 doesn't seem to be compatible with MS Visual Studio 2015).
Related Question