Error with gpu codegen

20 views (last 30 days)
Alessandro
Alessandro on 10 Sep 2025
Commented: Alessandro on 12 Sep 2025
I ran this code on my computer
clear,clc,close all
Params.r = 0.0476; % 0.0476;
Params.w = 0.172;
vfoptions = struct();
vfoptions.method = 1; %1 = vec; 2= gpuarray, 3 = mexcuda
% OMITTED
GEPrices0 = zeros(2,1);
GEPrices0(1) = Params.r;
GEPrices0(2) = Params.w;
a_grid = linspace(0,130,1000)';
z_grid = linspace(0,10,40)';
pi_z = zeros(40,40);
% Define variable size inputs
vs_a_grid = coder.typeof(a_grid,[4001,1],1) ;
% Call codegen
cfg = coder.gpuConfig('mex');
cfg.GenerateReport = true;
codegen -config cfg fun_VFI_cuda2 -args {zeros(2,1), vs_a_grid, z_grid, pi_z, Params, vfoptions} -o fun_VFI_cuda2_mex
where the function fun_VFI_cuda2 is defined in a separate M-file as
function [V,Policy] = fun_VFI_cuda2(p_eqm, a_grid, z_grid, pi_z, Params, vfoptions)
disp('ciao')
V=0;
Policy=0;
end
and I got the following (long) error message:
------------------------------------------------------------------------
[1/10] cl /c /Zc:__cplusplus /Zp8 /GR /W3 /EHs /nologo /MD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /DMATLAB_MEX_FILE /O2 /Oy- /DNDEBUG /fp:strict /utf-8 /I "." /I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" /I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" /I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" /I ".\interface" /I "C:\Program Files\MATLAB\R2024b\extern\include" /I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H interface\_coder_fun_VFI_cuda2_info.cpp /Fobuild\win64\_coder_fun_VFI_cuda2_info.obj
_coder_fun_VFI_cuda2_info.cpp
[2/10] nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" rt_nonfinite.cu -o build\win64\rt_nonfinite.obj
FAILED: build/win64/rt_nonfinite.obj
nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" rt_nonfinite.cu -o build\win64\rt_nonfinite.obj
C:\Program Files\MATLAB\R2024b\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.
rt_nonfinite.cu
[3/10] nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" interface\_coder_fun_VFI_cuda2_api.cu -o build\win64\_coder_fun_VFI_cuda2_api.obj
FAILED: build/win64/_coder_fun_VFI_cuda2_api.obj
nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" interface\_coder_fun_VFI_cuda2_api.cu -o build\win64\_coder_fun_VFI_cuda2_api.obj
C:\Program Files\MATLAB\R2024b\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.
_coder_fun_VFI_cuda2_api.cu
[4/10] nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" fun_VFI_cuda2_initialize.cu -o build\win64\fun_VFI_cuda2_initialize.obj
FAILED: build/win64/fun_VFI_cuda2_initialize.obj
nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" fun_VFI_cuda2_initialize.cu -o build\win64\fun_VFI_cuda2_initialize.obj
C:\Program Files\MATLAB\R2024b\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.
fun_VFI_cuda2_initialize.cu
[5/10] nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" fun_VFI_cuda2.cu -o build\win64\fun_VFI_cuda2.obj
FAILED: build/win64/fun_VFI_cuda2.obj
nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" fun_VFI_cuda2.cu -o build\win64\fun_VFI_cuda2.obj
C:\Program Files\MATLAB\R2024b\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.
fun_VFI_cuda2.cu
[6/10] nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" fun_VFI_cuda2_terminate.cu -o build\win64\fun_VFI_cuda2_terminate.obj
FAILED: build/win64/fun_VFI_cuda2_terminate.obj
nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" fun_VFI_cuda2_terminate.cu -o build\win64\fun_VFI_cuda2_terminate.obj
C:\Program Files\MATLAB\R2024b\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.
fun_VFI_cuda2_terminate.cu
[7/10] nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" interface\_coder_fun_VFI_cuda2_mex.cu -o build\win64\_coder_fun_VFI_cuda2_mex.obj
FAILED: build/win64/_coder_fun_VFI_cuda2_mex.obj
nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" interface\_coder_fun_VFI_cuda2_mex.cu -o build\win64\_coder_fun_VFI_cuda2_mex.obj
C:\Program Files\MATLAB\R2024b\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.
_coder_fun_VFI_cuda2_mex.cu
[8/10] nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" cpp_mexapi_version.cpp -o build\win64\cpp_mexapi_version.obj
cpp_mexapi_version.cpp
[9/10] nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" fun_VFI_cuda2_data.cu -o build\win64\fun_VFI_cuda2_data.obj
FAILED: build/win64/fun_VFI_cuda2_data.obj
nvcc -c -rdc=true -Wno-deprecated-gpu-targets -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--display_error_number --diag_suppress=2381 --diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE --no-exceptions -Xcompiler "/EHa" -noprof -ldir "C:\Program Files\MATLAB\R2024b/bin/win64" -Xcompiler "/utf-8" -I "." -I "C:\Users\aledi\Dropbox\1 - RESEARCH PROJECTS\19_MatlabExecutablePaper\SHARED\Code BueraShin_gpuarray" -I "C:\Program Files\MATLAB\R2024b\toolbox\gpucoder\src\gpucoderrt\export\include\gpucoderrt" -I "C:\Program Files\MATLAB\R2024b\sys\cuda\win64\cuda\include" -I ".\interface" -I "C:\Program Files\MATLAB\R2024b\extern\include" -I "." -DMW_CUDA_ARCH=900 -DMW_GPU_MEMORY_MANAGER -DMODEL=fun_VFI_cuda2_mex -DMW_NEEDS_VERSION_H -arch sm_90 -I "C:\Program Files\MATLAB\R2024b/simulink/include" -I "C:\Program Files\MATLAB\R2024b/toolbox/shared/simtargets" fun_VFI_cuda2_data.cu -o build\win64\fun_VFI_cuda2_data.obj
C:\Program Files\MATLAB\R2024b\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.
fun_VFI_cuda2_data.cu
ninja: build stopped: subcommand failed.
------------------------------------------------------------------------
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
Error in test_codegen (line 20)
codegen -config cfg fun_VFI_cuda2 -args {zeros(2,1), vs_a_grid, z_grid, pi_z, Params, vfoptions} -o fun_VFI_cuda2_mex
^^^^^^^
To give some context, the exact same code compiled just fine on another computer of mine. The current computer where I got the error has these specs:
  • intel-oneapi-base-toolkit-2025.2.1.46 and intel-oneapi-hpc-toolkit-2025.2.1.46
  • Visual Studio 2022 version 17.14.13
  • NVIDIA GeForce RTX 5080 Laptop GPU
  • Processor: Intel Core Ultra 9 275HK, 2700 Mhz, 24 Core(s), 24 Logical Processor(s)
Note 1: I typically use the Fortran compiler, but I think the intel one api toolkit that I have should also come with a C/CUDA compiler. The other PC where everything runs fine has a (slightly older) version of the same intel oneapi toolkit. If I type mex -setup, I get
MEX configured to use 'Microsoft Visual C++ 2022 (C)' for C language compilation.
Note 2: Every time I start a new Matlab session, Matlab compiles some GPU libraries (since the GPU is has compute capability higher than 9.0) but all the gpuArray, arrafun etc. commands run as expected. The problem is only with gpu codegen.
Note 3: I can include the function fun_VFI_cuda if requested, but as it compiles OK on my other computer, I don't think there is an issue there.
Any help is greatly appreciated!
  2 Comments
Alessandro
Alessandro on 10 Sep 2025
I found a file called .ninja_log that may give some information to people who know more than me
# ninja log v5
13 199 7792485539056911 build/win64/_coder_fun_VFI_cuda2_info.obj ad9ee53282121d95
22 1692 7792485553907161 build/win64/cpp_mexapi_version.obj faf0a21a2d8afdb3
Alessandro
Alessandro on 10 Sep 2025
To investigate the issue, I ran gpucoderSetup and I got this:

Sign in to comment.

Answers (1)

Nathaniel
Nathaniel on 11 Sep 2025
Hi Alessandro, I see you are getting a compiler error when compiling GPU MEX code in MATLAB R2024b. Note this section from the build log:
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.
The error is caused by the fact that, in R2024b, GPU Coder uses NVIDIA CUDA Toolkit version 12.2. CUDA 12.2 requires specific versions of the Microsoft Visual C++ compiler, which is included with the Microsoft Visual Studio IDE. See the CUDA 12.2 Installation Guide for Microsoft Windows Documentation on the NVIDIA website for the list of supported host compilers for Windows.
CUDA 12.2 supports Visual Studio IDE versions 15.x through 17.0. If you have the Microsoft Visual C++ compiler version, CUDA 12.2 supports versions 19.1x through 19.3x of the Microsoft Visual C++ compiler. Using the latest version of Visual Studio 2022, version 17.44 (which includes compiler version 19.44), generates an eror when you compile the code.
To resolve this issue, install one of these Visual Studio IDE versions:
  • Microsoft Visual Studio 2017 version 15.x (includes Visual C++ compiler version 19.1x)
  • Microsoft Visual Studio 2019 version 16.x (includes Visual C++ compiler version 19.2x)
  • Microsoft Visual Studio 2022 version 17.0 through 17.09 (includes Visual C++ compiler version 19.3x)
  2 Comments
Alessandro
Alessandro on 11 Sep 2025
Edited: Alessandro on 11 Sep 2025
I checked the version of Visual Studio I have, please see attached screenshot. I have MVS Version 17.14. How do I download MVS Version 17.0 through 17.09? I went on microsoft website but I was not able to locate older downloads (I found only MVS 2019 but I would like 2022) Thanks!
Alessandro
Alessandro on 12 Sep 2025

Since downloading older versions of VS is complicated (at least for me), would using Matlab 2025a solve this problem?

Sign in to comment.

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!