1. clangd 报错 --option-file, --gencode=--generate-code=arch=compute_75,code=[compute_75,sm_75], 这类问题,原因在于clangd 和 nvcc的命令行指令不太一样,在项目根目录下新建一个.clangd文件,然后写下下面这个进行屏蔽就好
CompileFlags:
Remove:
- "--expt-extended-lambda"
- '-gencode=arch=compute_60,code="sm_60,compute_60"'
- "-rdc=true"
- '-forward-unknown-to-host-compiler'
- '--expt-relaxed-constexpr'
- '--generate-code=arch=compute_75,code=[compute_75,sm_75]'
- '-forward-unknown-to-host-compiler'
- '-arch=native'
- '--options-file'
- '-Xcompiler=-fPIC'
Add:
- '-std=c++17'
- '--cuda-gpu-arch=sm_75'
Compiler: clang++
2. 某些头文件,在普通的.h中,clangd可以关联上不会报错,但切换到.cuh下就会报错,这是因为nvcc编译器没有包含相应的头文件路径,在CMakeLists中加入相应路径就好, 比如我的就是无法找到armadillo库,加入头文件目录即可
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -I${CMAKE_SOURCE_DIR}/../ArmadilloInstalled/include")