Why do I get errors when running the MEX CUDA example with up-to-date versions of Visual Studio Compilers using the Parallel Computing Toolbox R2025a?
39 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 28 Lug 2025
Risposto: MathWorks Support Team
il 28 Lug 2025
Why do I get errors when running the MEX CUDA example with up-to-date versions of Visual Studio Compiler using the Parallel Computing Toolbox R2025a?
I am using the Mandelbrot example and want to compile the CUDA/C++ code to MEX.
Running the command as is, I get this error with Visual Studio 2022 installed and selected:
C:\Program Files\MATLAB\R2025a\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.
Adding the suggested workaround to the call like this:
>> mexcuda NVCCFLAGS="--allow-unsupported-compiler" -ptx pctdemo_processMandelbrotElement.cu
I now get this error:
<MSVC installation directory>\include\yvals_core.h(902): error: static assertion failed with "error STL1002: Unexpected compiler version, expected CUDA 12.4 or newer."
static_assert(false, "error " "STL1002" ": " "Unexpected compiler version, expected CUDA 12.4 or newer.");
What is the reason for these errors and how can I resolve them?
I have a newer version than 12.4 of the CUDA Toolkit installed on my system.
Risposta accettata
MathWorks Support Team
il 29 Lug 2025
MATLAB ships with a specific version of the CUDA Toolkit, the system installation is not used. For R2025a, the toolkit version 12.2 is used.
You can find an overview of the Toolkit version for each release here:
Some of these not current Toolkit versions also require an older version of the compiler, see the remark in the GPU Coder prerequisites
MATLAB has only been qualified with the supported Toolkit and Compiler combination. Please downgrade your Visual Studio installation so that it includes a supported compiler for the CUDA Toolkit.
If you want to use the current installation, please note, that the functionality cannot be guaranteed. A workaround for the Toolkit and Compiler version mismatches is described here on Stack Overflow:
The corresponding call then looks like this:
>> mexcuda NVCCFLAGS="--allow-unsupported-compiler" -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -ptx pctdemo_processMandelbrotElement.cu
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with GPU Coder in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!