フィルターのクリア

How to get mexcuda running - compiler settings

77 ビュー (過去 30 日間)
Amos
Amos 2016 年 10 月 25 日
回答済み: Walter Roberson 2024 年 7 月 15 日 23:07
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 ...

採用された回答

Amos
Amos 2016 年 10 月 27 日
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).
  5 件のコメント
James Trimble
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.
Amos
Amos 2018 年 7 月 4 日
Yes, I guess then it really needs to be this one specific set of installs. My original question was also driven by the wrong assumption that little deviations should be OK ;)
Your question is not answered, though ... where is a reliable list of combinations of versions that would work? In Linux things are easier because there the Gnu C++ compiler which comes with the OS does the job.

サインインしてコメントする。

その他の回答 (4 件)

Prakash Devaraju
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 件のコメント
Cindy Yuan
Cindy Yuan 2021 年 9 月 3 日
hi what's the version of your cuda toolkit?
Connor Gallimore
Connor Gallimore 2024 年 7 月 15 日 22:54
Deep in this rabbithole for EXACTLY this. thank you!

サインインしてコメントする。


Riccardo Melani
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
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).
Ming-Ching
Ming-Ching 2023 年 9 月 19 日
Thanks a lot! Above steps solve my problem!!

サインインしてコメントする。


Natalya Shelchkova
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.

Walter Roberson
Walter Roberson 2024 年 7 月 15 日 23:07
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.)

カテゴリ

Help Center および File ExchangeMATLAB Compiler SDK についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by