Specifying multiple architectures on Visual Studio, JIT

On Linux I can compile CUDA code for several different gencodes, and then the nvcc will do a JIT to pick the right version to use. This technique is shown in basically every CUDA sample’s makefile:

# CUDA code generation flags
ifneq ($(OS_ARCH),armv7l)
GENCODE_SM10    := -gencode arch=compute_10,code=sm_10
GENCODE_SM20	:= -gencode arch=compute_20,code=sm_20
GENCODE_SM30	:= -gencode arch=compute_30,code=sm_30
GENCODE_SM32	:= -gencode arch=compute_32,code=sm_32
GENCODE_SM35	:= -gencode arch=compute_35,code=sm_35
GENCODE_SM50	:= -gencode arch=compute_50,code=sm_50
GENCODE_SMXX	:= -gencode arch=compute_50,code=compute_50

How do I do this in Visual Studio? Is it possible? Right now I have a props file with just this line:


I tried:


But get this error:
Code Generation value is not in the expected format ‘[Arch],[Code]’.

I looked this up on google but haven’t found any one trying to compile for more than one architecture at a time on Visual Studio.

The cuda samples provided with windows install already indicate how to do this. All of the cuda sample projects are already set up to compile for multiple architectures. Typically you would go into the project properties and select the code generation there (under cuda compiler settings). It can also be done on a file-by-file basis. I wouldn’t suggest modifying props file as the way to do this.

Look at the first answer here:


Yes, it only has one target specified, but if you look at the sample code projects in the same area, you will find out how multiple targets are specified.

So simple once you know where to look! Thanks txbob!