mexcuda() can't find Visual Studio 2022, but mex() can.
45 views (last 30 days)
Show older comments
In R2024a, I encounter the following when trying to compile with mexcuda in conjunction with Visual Studio 2022.
>> mexcuda -largeArrayDims vectorAdd.cu
Building with 'NVIDIA CUDA Compiler'.
Error using mex
vectorAdd.cu
C:\Program Files\MATLAB\R2024a\sys\cuda\win64\cuda\include\crt/host_config.h(164): fatal error C1189:
#error: -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022
(inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this
version check; however, using an unsupported host compiler may cause compilation failure or incorrect run
time execution. Use at your own risk.
Error in mexcuda (line 185)
[varargout{1:nargout}] = mex(mexArguments{:});
mexcuda() seems to think Visual Studio 2022 is not installed, but mex() sees that it is,
>> mex -setup C++
MEX configured to use 'Microsoft Visual C++ 2022' for C++ language compilation.
I would welcome any and all troubleshooting advice.
If it matters, here are the details of my Cuda Toolkit installation,
>> !nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Sep_12_02:55:00_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.77
Build cuda_12.6.r12.6/compiler.34841621_0
1 Comment
Accepted Answer
Avgoustinos Vouros
on 10 Oct 2024
I believe the issue is incompatibility among the specific versions of Visual Studio 2022, CUDA, and MATLAB:
- MATLAB R2024a comes with CUDA Toolkit 12.2 which is compatible with Visual Studio 2022 but specifically up to v17.9.x.
- CUDA 12.4 was the version that started supporting Visual Studio 2022 (v17.10) onward.
- Earlier CUDA versions do work with Visual Studio 2022 (v17.9.x) but not Visual Studio 2022 (v17.10) or later.
- There is the way to downgrade Visual Studio 2022 to an earlier version to make it compatible with an earlier CUDA version but only the Professional edition of Visual Studio allows that. Alternatively, Visual Studio 2019 should work in your case.
You may want to use the -v flag in your mexcuda command which should list what MATLAB attempts to do in order to compile your code. I believe the log will indicate that the incompatibility is the use of CUDA Toolkit 12.2 with your specific Visual Studio 2022 version.
5 Comments
Avgoustinos Vouros
on 1 Nov 2024
Edited: Avgoustinos Vouros
on 1 Nov 2024
This is where things get even trickier: when you download the toolkit and access the header files, you can see that the cutoff is actually v17.9.x rather than v17.0. It would have been quite constrained if it was exactly until 17.0, but this certainly adds more confusion.
Joss Knight
on 4 Nov 2024
Thanks, Joss, though maybe it's worth mentioning, the data I found there says that CUDA 12.2 is compatible with VS2022 upt to v17.0, not up to v17.9.x as mentioned by @Avgoustinos Vouros.
Well yes. 17.0 will have been the latest version they tested against when documenting and so it is not wrong of course. The real issue here is how difficult Microsoft make it to download an older version of the Community Edition. So knowing that if only you could download 17.0 it would be supported is hardly comforting.
More Answers (0)
See Also
Categories
Find more on Get Started with GPU Coder 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!