cuda header error related to unsupported GNU version while building a program

Trying to build Gunrock, I hit the following error

$ make
[  1%] Building NVCC (Device) object gunrock/CMakeFiles/gunrock.dir/__/externals/moderngpu/src/gunrock_generated_mgpucontext.cu.o
In file included from /usr/local/cuda/include/host_config.h:50:0,
                 from /usr/local/cuda/include/cuda_runtime.h:78,
                 from <command-line>:0:
/usr/local/cuda/include/crt/host_config.h:121:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!
  ^~~~~
CMake Error at gunrock_generated_mgpucontext.cu.o.cmake:222 (message):
  Error generating
  /home/mahmood/gunrock/build/gunrock/CMakeFiles/gunrock.dir/__/externals/moderngpu/src/./gunrock_generated_mgpucontext.cu.o

gunrock/CMakeFiles/gunrock.dir/build.make:119: recipe for target 'gunrock/CMakeFiles/gunrock.dir/__/externals/moderngpu/src/gunrock_generated_mgpucontext.cu.o' failed
make[2]: *** [gunrock/CMakeFiles/gunrock.dir/__/externals/moderngpu/src/gunrock_generated_mgpucontext.cu.o] Error 1
CMakeFiles/Makefile2:117: recipe for target 'gunrock/CMakeFiles/gunrock.dir/all' failed
make[1]: *** [gunrock/CMakeFiles/gunrock.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2

The cuda is 9.1, gcc is 6 and ubuntu is 17.10. The error seems to be related with cuda according to the call stack. It is weird because I have built toolkit with the same gcc. Any idea?

cmake might be using a different version of CUDA installed on your machine or a different version of the GNU compiler than the one you think it is using.