我有以下用于生成 750 cuda 拱门的 cmake 和 cuda 代码,但是,这总是导致CUDA_ARCH = 300(2080 ti 与 cuda 10.1)。set_property
和都试过了target_compile_options
,都失败了。我们有解决方案吗?在这种情况下cuda_add_executable
, cuda_add_library
让-gencode
零件有效吗?</p>
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();
}