cmake-gui: Need field to set CMAKE_CUDA_HOST_COMPILER
Trying to configure CMakeLists.txt, I got
this CMake output.
The CXX compiler identification is GNU 5.4.0 The CUDA compiler identification is NVIDIA 8.0.61 Check for working CXX compiler: /usr/bin/g++-5 Check for working CXX compiler: /usr/bin/g++-5 -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done Check for working CUDA compiler: /opt/cuda/bin/nvcc Check for working CUDA compiler: /opt/cuda/bin/nvcc -- broken CMake Error at /usr/share/cmake-3.9/Modules/CMakeTestCUDACompiler.cmake:45 (message): The CUDA compiler "/opt/cuda/bin/nvcc" is not able to compile a simple test program.It fails with the following output:
Change Dir: /tmp/cuda_test-build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_43008/fast"
/usr/bin/make -f CMakeFiles/cmTC_43008.dir/build.make CMakeFiles/cmTC_43008.dir/build
make[1]: Verzeichnis „/tmp/cuda_test-build/CMakeFiles/CMakeTmp“ wird betreten
Building CUDA object CMakeFiles/cmTC_43008.dir/main.cu.o
/opt/cuda/bin/nvcc -x cu -c /tmp/cuda_test-build/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_43008.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 CMakeFiles/cmTC_43008.dir/cmake_device_link.o
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_43008.dir/dlink.txt --verbose=1
/opt/cuda/bin/nvcc -Xcompiler=-fPIC -Wno-deprecated-gpu-targets -shared -dlink CMakeFiles/cmTC_43008.dir/main.cu.o -o CMakeFiles/cmTC_43008.dir/cmake_device_link.o
Linking CUDA executable cmTC_43008
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_43008.dir/link.txt --verbose=1
g++ CMakeFiles/cmTC_43008.dir/main.cu.o CMakeFiles/cmTC_43008.dir/cmake_device_link.o -o cmTC_43008 -L"/opt/cuda/lib64/stubs" -L"/opt/cuda/lib64" -lcudadevrt -lcudart_static -lrt -lpthread -ldl
/usr/bin/ld: CMakeFiles/cmTC_43008.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: Fehler: ld gab 1 als Ende-Status zurück
make[1]: *** [CMakeFiles/cmTC_43008.dir/build.make:117: cmTC_43008] Fehler 1
make[1]: Verzeichnis „/tmp/cuda_test-build/CMakeFiles/CMakeTmp“ wird verlassen
make: *** [Makefile:126: cmTC_43008/fast] Fehler 2
CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:13 (project)
Configuring incomplete, errors occurred! See also "/tmp/cuda_test-build/CMakeFiles/CMakeOutput.log". See also "/tmp/cuda_test-build/CMakeFiles/CMakeError.log".
The important lines seem to be
Check for working CXX compiler: /usr/bin/g++-5
-
g++ CMakeFiles/cmTC_43008.dir/main.cu.o
Shouldn't it beg++-5
?
My default system compiler is g++ (version 7) (not supported by CUDA), for this project the native compiler was set to g++-5 (supported by CUDA).
I have to set CMAKE_CUDA_HOST_COMPILER
to /usr/bin/g++-5
to solve the error.