CMake找不到CUDA:“找不到cmake模块文件:CMakeDetermineCUDACompiler.cmake”。 [英] CMake cannot find CUDA: "Could not find cmake module file: CMakeDetermineCUDACompiler.cmake"

查看:1372
本文介绍了CMake找不到CUDA:“找不到cmake模块文件:CMakeDetermineCUDACompiler.cmake”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写需要cuda功能的CMake文件。咨询​​此答案,我将此行添加到了CMakeLists.txt:

I'm trying to write a CMake file which needs cuda functionalities. Consulting this answer, I added this line to my CMakeLists.txt:

set(CMAKE_CUDA_COMPILER  /usr/local/cuda-9.2/bin/nvcc)

但是使用 cmake 命令时仍然抱怨:

But when using cmake command it still complains:

yuqiong@yuqiong-G7-7588:/media/yuqiong/DATA/alexnet/src/cpp/train$ cmake .
CMake Error: Could not find cmake module file: CMakeDetermineCUDACompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CUDA_COMPILER_ENV_VAR
CMake Error: Could not find cmake module file: /media/yuqiong/DATA/alexnet/src/cpp/train/CMakeFiles/3.5.1/CMakeCUDACompiler.cmake
CMake Error: Could not find cmake module file: CMakeCUDAInformation.cmake
CMake Error: Could not find cmake module file: CMakeTestCUDACompiler.cmake
-- Configuring incomplete, errors occurred!
See also "/media/yuqiong/DATA/alexnet/src/cpp/train/CMakeFiles/CMakeOutput.log".

这似乎令人困惑,因为我不知道在哪里还要设置环境变量?知道为什么 set 命令不能帮助cmake查找nvcc编译器吗?

Which seems confusing, as I don't know where else to set the environment variable? Any idea why the set command does not help cmake find the nvcc compiler?

以防万一,这里是我的 CMakeLists.txt

Just in case helpful, here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_CUDA_COMPILER  /usr/local/cuda-9.2/bin/nvcc)

project(train LANGUAGES CXX CUDA)

set(CMAKE_CXX_STANDARD 14)
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )


add_executable(train train.cu)
target_link_libraries( train ${OpenCV_LIBS} )


推荐答案

实际上,您需要在Linux上使用CMake 3.8才能使用 project(train LANGUAGES CUDA)。以前,您需要使用以下旧方法:

Actually, you need CMake 3.8 on Linux to use project(train LANGUAGES CUDA). Before, you need the old way with:

FindPackage(CUDA)

并手动添加库。

失败是因为您的CUDA没有本机支持CMake版本,请使用旧方法。

The failure is because there is no native support for CUDA in your CMake version, use the old method.

这篇关于CMake找不到CUDA:“找不到cmake模块文件:CMakeDetermineCUDACompiler.cmake”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆