I am creating this blog as a reference for the common CMake issues that I have during my projects. I end up solving them at the time but when the issue hits me again in a few months, I kind of not remember the details of how I tackled it the previous time. As many a times these issues are specific to the machine that I am on – the modules, platforms, versions, environment variables etc, the common solution of google search is only partially helpful. This blog is intended as a solution for the issues.
Issue :
The C compiler
<C-compiler>
is not able to compile a simple test program.
This is happening on Jetbrains and not when I try to build from terminal. Intel C compiler was complaining as I didn’t have licence for it on my local machine. So, I am now building it with gnu/6.3.0 . There are two solutions for it. First, specify the compiler in CLion’s settings. The second, and the one that I am using right now, is to build it first on a terminal with the gcc compiler that I want. And since it gets stored in the CMakeCache.txt, CMake just reads it from there itself. It will create problem if I try to delete the cache and try to build again, but now I know how to handle it.
——————————————————————–
Issue
CUDA_CUDA_LIBRARY not found
This issue comes up while trying to run cmake on a machine which doesn’t have nvidia driver installed. So, to solve this one, just switch over to a machine that has nvida drivers, not just CUDA toolkit.
——————————————————————–
Issue
C++ 11/14/17 standard flags don’t get propagated over to nvcc
Solution
set_property(TARGET target PROPERTY CUDA_STANDARD 11 )
——————————————————————–
Issue
no kernel image is available for execution on the device
This error message comes up while launching the kernel if the cuda code is not compiled for the specific architecture of the gpu device. Solution for the problem is to add the following nvcc flags
–gencode arch=compute_61,code=compute_61.
This is for the Pascal architecture with compute capability 6.1. For k80, the compute capability is 3.7. You can add as many cc as you want in order to have backward compatibility, but at the same time your performance may hamper. It’s better to know your architecture’s cc and build for as few as you can.
——————————————————————–
Issue
CMake doesn’t identify the correct C/CXX version which was set using the module. It recognizes the one at /usr/local/c++
Solution :
This should be set by the module itself. However, as it is not set, we can set it by
export CC=<path-to-icc>
export CXX=<path-to-icpc>
——————————————————————–
Issue
CMake is not able to pass the -G flag to debug the cuda portion of the code
Solution :
I haven’t found the exact method yet. But what seems to be workin for now is to simply use
set cuda break_on_launch all
after reaching the host level code where the device kernel is being called.