0

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

1 回答 1

1

将我的评论更改为答案:

project(Hello CUDA) 
enable_language(CUDA) 
set_property(TARGET oounne PROPERTY CUDA_ARCHITECTURES 75)
于 2022-01-11T13:43:29.300 回答