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).
How to get mexcuda running - compiler settings
46 views (last 30 days)
Show older comments
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 ...
0 Comments
Accepted Answer
Amos
on 27 Oct 2016
5 Comments
James Trimble
on 3 Jul 2018
Thanks @Amos. I'm using Matlab 2017b. I found the best method is to start with your Matlab version, find out which CUDA version it supports, then look at the supported compilers for that CUDA version. For me this was Matlab 2017b->CUDA 8->VS 2015.
More Answers (4)
Prakash Devaraju
on 13 Dec 2020
Edited: Prakash Devaraju
on 13 Dec 2020
Just a novice here, got the visual studio compiler to work instead of mingw-w64. It seems the CUDA and compiler have to match. You can downgrade one or upgrade another. Running Matlab R2020b and Visual studio 2019. Visual studio 2013 seems unsupported in R2020b. Installed visual studio 2019 earlier without installing C++ components and mex was defaulting to mingw-w64 compiler. And the latest visual studio installation is too much for a beginner - didn't know which component is required to help the compiler and so selected all the latest versions with C++ and restarted the computer after installing. Now mex -setup gave me the option to choose Microsoft Visual C++ 2019 (C) and now can get to a GUI.
If anyone is trying to use Kilosort GUI for neuropixels with R2020b in Windows 10, try installing visual studio 2019 community with C++ components. Then choose the Visual studio compiler in matlab using mex -setup, followed by mexGUPall.m and kilosort.m
2 Comments
Riccardo Melani
on 23 May 2023
Edited: Riccardo Melani
on 23 May 2023
Hi,
This is what I get, using MATLAB R2022b...... (see attachment)
Any help will be appreciated!
Thanks!!!
3 Comments
Emily Wong
on 27 Jul 2023
Edited: Emily Wong
on 27 Jul 2023
This is what I did with Matlab 2021a and 2022a:
Added C++ to Visual Studio 2019 via the Installer.
Enter command gpuDevice to show the CUDA toolkit version (11.0 is compatible with 2021a).
Restarted PC.
Installed the GUI Layout Toolbox by David Sampson (as prompted).
Restarted Matlab.
Enter mex -setup C++ (to check if Matlab now recognizes VS C++ as its compiler).
Natalya Shelchkova
on 5 May 2023
People are misunderstanding one crucial thing. Compute Capability is not the same as CUDA version. Many people are seeing 7.5 as their compute capability, this is the number returned by gpuDeviceTable and gpuDevice and interpreting that as the required CUDA version.
Compute Capability 7.5 is totally fine with the current version of CUDA toolkit (12.1 at the time of writing this). That version of the tool kit is cool with MS Visual Studio 2022 17.0 or 2019 16.x (I suggest the latter). If you have the correct version of visual studio, then download cuda toolkit, then set the mexCuda compiler, it will run smoothly.
It seems like it can work with the super old visual studio, but that version of visual studio came out wayyyyy before the graphics cards in most machines and before even kilosort, so tracking down Visual Studio 2013 and CUDA toolkit 7.5 is a crazy unnecessary step.
0 Comments
Walter Roberson
on 15 Jul 2024
and Microsoft Visual Studio 2015 (community edition).
That was the problem. All versions of MATLAB that supported VS 2015 needed the Professional edition.
R2016b and R2017a supported all versions of VS 2017, provided a patch was installed.
R2017b up through R2024a support all editions of VS 2017, without needing a patch.
(Some newer releases of MATLAB support newer versions of Visual Studio.)
0 Comments
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!