GPU coder configured for MinGW-w64 C/C++/Fortran compiler passes invalid options to nvcc. How to remove?
5 views (last 30 days)
Show older comments
Passing MATLAB code to GPU coder (v24.02) fails while building MEX as the build script invokes nvcc with bare options like "-Wno-stringop-overflow", which I'm guessing should be "-Xcompiler -Wno-stringop-overflow" as nvcc (v12.8) does not accept the warning disabling options but g++ does. From settings or coder.gpuConfig, I can only add compiler flags, but how do I remove or change the build script to correct the options/flags sent to nvcc?
0 Comments
Answers (1)
Nathaniel
on 6 Feb 2025
Edited: Nathaniel
on 6 Feb 2025
Hey Jeffrey,
I see you're using GPU Coder with MinGW to build MEX, and the compiler is receiving some invalid options. Please note that GPU Coder does not support MinGW. It only supports using the Microsoft Visual C/C++ compiler. See the supported compilers for GPU Coder in R2024b here:
GPU Coder uses CUDA version 12.2 to build MEX in R2024b, so the compiler should be compatible with CUDA 12.2. This version of CUDA supports both Visual Studio 2017 or 2019. See Visual Studio Older Downloads to get Visual Studio 2017 or 2019.
You can also use Microsoft Visual Studio 2022, but CUDA 12.2 only supports Visual Studio 2022 version 17.0.
Is Visual C/C++ available to you? If you have it installed, you can enter mex -setup C++ in the MATLAB command line to select the Visual C/C++ compiler.
Thanks,
Nathaniel
2 Comments
Chao Luo
on 7 Feb 2025
Hi Jeffrey,
Many flags are hardcoded and cannot be removed using config files. You can modify the genearted build.ninja to remove the flags in the codegen folder. You can run !YouFcn_mex.bat to recompile the generated code.
However, even if you removed the unsupported flags, the compilation would still fail since NVCC would error out complaining cl.exe not found.
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!