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
54 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Amos
2016-10-27
5 个评论
James Trimble
2018-7-3
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.
更多回答(4 个)
Prakash Devaraju
2020-12-13
编辑:Prakash Devaraju
2020-12-13
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 个评论
Riccardo Melani
2023-5-23
编辑:Riccardo Melani
2023-5-23
Hi,
This is what I get, using MATLAB R2022b...... (see attachment)
Any help will be appreciated!
Thanks!!!
3 个评论
Emily Wong
2023-7-27
编辑:Emily Wong
2023-7-27
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
2023-5-5
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 个评论
Walter Roberson
2024-7-15
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!