CMake 3.8.2 fails to configure minimal CUDA project.
Hello,
I decided to try the latest version of CMake (3.8.2) and test the newly added CUDA support. However, CMake is not able to configure a CUDA project at all. Here is the error I get when I try to configure my project:
user@neptune:~/code/cmake_test$ ~/opt/cmake/bin/cmake ./
-- The CUDA compiler identification is NVIDIA 8.0.44
-- Check for working CUDA compiler: /usr/bin/nvcc
-- Check for working CUDA compiler: /usr/bin/nvcc -- broken
CMake Error at /home/user/opt/cmake/share/cmake-3.8/Modules/CMakeTestCUDACompiler.cmake:45 (message):
The CUDA compiler "/usr/bin/nvcc" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /home/user/code/cmake_test/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_0680a/fast"
/usr/bin/make -f CMakeFiles/cmTC_0680a.dir/build.make
CMakeFiles/cmTC_0680a.dir/build
make[1]: Entering directory
'/home/user/code/cmake_test/CMakeFiles/CMakeTmp'
Building CUDA object CMakeFiles/cmTC_0680a.dir/main.cu.o
/usr/bin/nvcc -x cu -c
/home/user/code/cmake_test/CMakeFiles/CMakeTmp/main.cu -o
CMakeFiles/cmTC_0680a.dir/main.cu.o
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are
deprecated, and may be removed in a future release (Use
-Wno-deprecated-gpu-targets to suppress warning).
Linking CUDA device code
/home/user/code/cmake_test/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_0680a.dir/cmake_device_link.o
/home/user/opt/cmake/bin/cmake -E cmake_link_script
CMakeFiles/cmTC_0680a.dir/dlink.txt --verbose=1
/usr/bin/nvcc -Xcompiler=-fPIC -shared -dlink
CMakeFiles/cmTC_0680a.dir/main.cu.o -o
CMakeFiles/cmTC_0680a.dir/cmake_device_link.o
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are
deprecated, and may be removed in a future release (Use
-Wno-deprecated-gpu-targets to suppress warning).
Linking CUDA executable cmTC_0680a
/home/user/opt/cmake/bin/cmake -E cmake_link_script
CMakeFiles/cmTC_0680a.dir/link.txt --verbose=1
g++ CMakeFiles/cmTC_0680a.dir/main.cu.o
CMakeFiles/cmTC_0680a.dir/cmake_device_link.o -o cmTC_0680a
-L"/usr/lib/x86_64-linux-gnu/stubs" -lcudadevrt -lcudart_static -lrt
-lpthread -ldl
/usr/bin/ld: CMakeFiles/cmTC_0680a.dir/main.cu.o: relocation R_X86_64_32
against `.bss' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_0680a.dir/build.make:116: recipe for target 'cmTC_0680a'
failed
make[1]: *** [cmTC_0680a] Error 1
make[1]: Leaving directory
'/home/user/code/cmake_test/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_0680a/fast' failed
make: *** [cmTC_0680a/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/home/user/code/cmake_test/CMakeFiles/CMakeOutput.log".
See also "/home/user/code/cmake_test/CMakeFiles/CMakeError.log".
g++ --version gives:
g++ (Debian 6.3.0-18) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
nvcc --version gives:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Sep__4_22:14:01_CDT_2016
Cuda compilation tools, release 8.0, V8.0.44
Any idea why is this happening? In general, I have no problems compiling CUDA code using the old CMake style (i.e., via the FindCUDA.cmake module). My OS is an up-to-date Debian (Testing). CMake is installed manually (downloaded directly from the CMake Web site).
Thanks in advance.