How to get mexcuda running - compiler settings

조회 수: 92 (최근 30일)
Amos
Amos 2016년 10월 25일
댓글: Ming-Ching 2023년 9월 19일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

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
  댓글 수: 1
Cindy Yuan
Cindy Yuan 2021년 9월 3일
hi what's the version of your cuda toolkit?

댓글을 달려면 로그인하십시오.


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.

카테고리

Help CenterFile Exchange에서 GPU CUDA and MEX Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by