我正在学习CUDA,在运行CUDA脚本时,我收到一个错误:
失败:CUDA注解(_N):C++ -g C生成文件/Cuda_notes.dir/设备查询.cpp.o -o Cuda_notes &&:/usr/bin/ld文件夹:CMakeFiles/Cuda_notes.目录/设备查询.cpp.o:在函数_cudaGetErrorEnum(cudaError)': /home/xxx/CUDA/Cuda_notes/cuda-samples/Common/helper_cuda.h:54: undefined reference to
cudaGetErrorName' /usr/bin/ld:CMakeFiles/Cuda_notes.目录/设备查询.cpp.o:在函数main': /home/xxx/CUDA/Cuda_notes/deviceQuery.cpp:51: undefined reference to
cudaGetDeviceCount中'
我想知道应该将哪个命令添加到我的CMakeLists.txt中,当前的命令是:
cmake_minimum_required(VERSION 3.23)
#set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc")
set(CMAKE_CUDA_ARCHITECTURES "35;50;52;60;61;70;75;80;86")
project(Cuda_notes LANGUAGES CUDA CXX C)
#find_package(CUDAToolkit)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
include_directories(SYSTEM "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
#/home/xxx/CUDA/Cuda_notes/cuda-samples/Common
include_directories(SYSTEM "/home/xxx/CUDA/Cuda_notes/cuda-samples/Common")
include_directories(.)
#link_libraries(cudart)
#target_link_libraries(cudart)
add_executable(Cuda_notes deviceQuery.cpp)
您的回答和指导将不胜感激!
1条答案
按热度按时间lymgl2op1#
感谢您的意见和分享的信息。我解决这个问题与以下
CMakeLists.txt
为: