关键两步:
1.add_executable指令换为cuda_add_executable
2.在cuda_add_executable执行前添加set_source_files_properties(${主c++文件名} PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
部分代码:
set(CUDA_GEN_CODE "-gencode=arch=compute_75,code=sm_75")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11 -O0 -Xcompiler -fPIC -g -w ${CUDA_GEN_CODE}")
set_source_files_properties(yolov5.cpp PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ)
cuda_add_executable(yolov5 ${PROJECT_SOURCE_DIR}/calibrator.cpp

本文介绍如何将C++源文件转换为CUDA可执行文件,重点在于如何使用`cuda_add_executable`替换`add_executable`,并在执行前设置CUDA源文件的特性。步骤包括设置编译选项和使用`set_source_files_properties`来指定CUDA源文件格式。
最低0.47元/天 解锁文章
1256

被折叠的 条评论
为什么被折叠?



