Linux环境CMake编译时报错找不到CUDA

CMakeLists.txt中有找CUDA的代码(例如find_package(CUDA REQUIRED)),系统也有装完整的NVIDIA驱动和CUDA环境(nvidia-smi能正常输出CUDA版本),但CMake编译报错:

Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY)

查看发现系统的cuda路径是/usr/local/cuda-11.2/,而CMake默认搜索CUDA的路径是/usr/local/cuda,增加一个软连接即可

sudo ln -s /usr/local/cuda-11.2/ /usr/local/cuda

你可能感兴趣的:(Linux环境CMake编译时报错找不到CUDA)