I have the following cmake and cuda code for generating a 750 cuda arch, however, this always results in a CUDA_ARCH = 300 (2080 ti with cuda 10.1). I tried both set_property
and target_compile_options
, which all failed. Do we have a solution for both cuda_add_executable
and cuda_add_library
in this case to make the -gencode
part effective?
cmake_minimum_required(VERSION 3.18)
project(Hello)
find_package(CUDA REQUIRED)
cuda_add_executable(oounne ttt.cu)
set_property(TARGET oounne PROPERTY CUDA_ARCHITECTURES 75)
#target_compile_options(oounne PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-gencode
arch=compute_75,code=sm_75>)
#include <cstdio>
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
__device__ void print_arch(){
const char my_compile_time_arch[] = STR(__CUDA_ARCH__);
printf("__CUDA_ARCH__: %s\n", my_compile_time_arch);
}
__global__ void example()
{
print_arch();
}
int main(){
example<<<1,1>>>();
cudaDeviceSynchronize();
}
Change my comment to an answer:
project(Hello CUDA)
enable_language(CUDA)
set_property(TARGET oounne PROPERTY CUDA_ARCHITECTURES 75)