MATLAB: Do I receive a ‘ Error C1189 #error: — unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!’ error in the CUDA ‘host_config.h’ file when trying to compile CUDA code with GPU Coder

GPU Coder

I am using MATLAB R2018a with GPU Coder. I have installed Visual Studio 2017 and CUDA 9.0, both of which are supported. When I try to compile any GPU Coder code, or run coder.checkGpuInstall('full'), I receive the following compiler error in a header, host_config.h:
ERROR: Error C1189 #error: -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!
What is going on?

Best Answer

The cause of this error is an update to Visual Studio 2017 that breaks support for CUDA.
Please note that Microsoft does not give users the ability to remove updates.
This is documented in the below CUDA Forum post:
The only solution is to install Visual Studio 2015 in some fashion. The easiest option is to install the Visual Studio 2015 Toolchain. You can do this by opening the Visual Studio Installer, selecting Modify, and selecting the Visual Studio 2015 toolchain.
You can also install the full version of Visual Studio 2015.
After doing this, make sure to change the compiler using 
mex -setup C
mex -setup C++
Related Question