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)
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".
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?
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} )