auto detect GPU arch in make file

Currently, I manually specify the architecture of GPU whenever I make:

NVCC_FLAGS = -arch=$(ARCH) -std=c++11 -lineinfo

Is there a way to automatically detect the architecture in the make file?

Your current approach is reasonable, but consider building a fat binary for all architectures you intend to support with your application. I consider building a fat binary, with one SASS instance for each architecture you need to support, plus a PTX instance of the latest supported architecture for forward compatibility, a best practice.

Note that your build machine (1) may not have a CUDA capable GPU (2) may use a GPU of a different architecture than the one on which your app needs to run (3) may contain multiple GPUs with different architectures. Consequently, GPU architecture auto detection during build does not seem to make much sense.

I’m very unfamiliar with linking and compiling so I’ll look more into fat binaries. Thanks a lot!