Proper way to handle both CUDA and non-CUDA build configurations in same Visual Studio project

Viewed 25

Our Visual Studio project features some CUDA code. But we also want our proejct to run without CUDA on a non-GPU machine. We have seperate build configurations for that i.e. Release and Release_GPU. To configure the CUDA build we use the CUDA build customizations for Visual Studio. For the non-GPU build (Release), the CUDA code is excluded via a conditional compilation constant GPU_BUILD (i.e. all code which is intended for Release_GPU only is encapsulated in #ifdef GPU_BUILD...#endif).

For now everything works but the catch is that we have to have CUDA installed even on the non-GPU machines. The CUDA build customizations are present even in the normal Release configuration and nvcc is unecessarily invoked on a non-GPU build.

Is there a better way to handle this?

We are using Visual Studio 2019 and CUDA 11.6.

PS: This is my first question. Please let me know if I did anything wrong.

0 Answers
Related