Troubleshooting `mexcuda` configuration for CUDA 12.2 on R2025a/R2025b(Windows)

I'm in trouble with configuring mexcuda system in windows.
According to the MathWorks GPU support documentation, CUDA 12.2 requires specific supported MSVC compilers (typically MSVC v141, v142, or early v143).
However, the currently available "Free" versions of Visual Studio (VS 2022 v17.10+ and the new VS 2026) does not compatible with CUDA 12.2.
Does anyone have a workaround for using the latest "Free" editions of Visual Studio with CUDA 12.2 toolkit in the R2025a/R2025b?

 Réponse acceptée

Hello,
Yes, there are workable paths, but each has tradeoffs because MATLAB R2025a/R2025b ship and use CUDA 12.2 internally for mexcuda (MATLAB ignores your system CUDA), and CUDA 12.2 does not recognize the newest MSVC toolset versions that come with the latest free Visual Studio editions (VS 2022 v17.10+ / VS 2026).
MATLAB R2025a invokes the CUDA 12.2 toolkit bundled inside MATLAB, not your system CUDA. So even if you installed CUDA 12.6 or 13.x systemwide, mexcuda still compiles with CUDA 12.2 headers/toolchain from matlabroot/sys/cuda/.
CUDA 12.2’s host_config.h gates MSVC versions and rejects newer MSVC (_MSC_VER ≥ 1940, i.e., VS2022 17.10+) with “unsupported Microsoft Visual Studio version” unless you pass the unsupportedcompiler flag. Microsofts STL also emits STL1002 expected CUDA 12.4 or newer when paired with MSVC 19.40+ (VS 17.10+)that combination expects CUDA 12.4.
The easiest workaround is to keep your current Visual Studio 2022 installed and simply add an older MSVC v143 minor toolset (e.g., 14.38 or 14.39). Install it from Visual Studio Installer → Individual components or via command line using the appropriate component ID.
Hope this helps.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with GPU Coder dans Centre d'aide et File Exchange

Produits

Version

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by