buildOpenCVTX2 error

hi,I want to install buildOpenCVTX2(3.3),but there is some errors,TX2 default GNU version is 5 and I set it to 4.7,but error is still exist,how should i do?
usr/local/cuda-8.0/include/host_config.h:119:2: error: #error – unsupported GNU version! gcc versions later than 5 are not supported!
#error – unsupported GNU version! gcc versions later than 5 are not supported!

Please share your configuration of opencv installation.

jetpack 3.1,following is the configuration of opencv installation

#!/bin/bash

License: MIT. See license file in root directory

Copyright© JetsonHacks (2017)

cd $HOME
sudo apt-get install -y
libglew-dev
libtiff5-dev
zlib1g-dev
libjpeg-dev
libpng12-dev
libjasper-dev
libavcodec-dev
libavformat-dev
libavutil-dev
libpostproc-dev
libswscale-dev
libeigen3-dev
libtbb-dev
libgtk2.0-dev
cmake
pkg-config

Python 2.7

sudo apt-get install -y python-dev python-numpy python-py python-pytest -y

GStreamer support

sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

git clone https://github.com/opencv/opencv.git
cd opencv
git checkout -b v3.3.0 3.3.0

This is for the test data

cd $HOME
git clone https://github.com/opencv/opencv_extra.git
cd opencv_extra
git checkout -b v3.3.0 3.3.0

cd $HOME/opencv
mkdir build
cd build

Jetson TX2

cmake
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=/usr
-DBUILD_PNG=OFF
-DBUILD_TIFF=OFF
-DBUILD_TBB=OFF
-DBUILD_JPEG=OFF
-DBUILD_JASPER=OFF
-DBUILD_ZLIB=OFF
-DBUILD_EXAMPLES=ON
-DBUILD_opencv_java=OFF
-DBUILD_opencv_python2=ON
-DBUILD_opencv_python3=OFF
-DENABLE_PRECOMPILED_HEADERS=OFF
-DWITH_OPENCL=OFF
-DWITH_OPENMP=OFF
-DWITH_FFMPEG=ON
-DWITH_GSTREAMER=ON
-DWITH_GSTREAMER_0_10=OFF
-DWITH_CUDA=ON
-DWITH_GTK=ON
-DWITH_VTK=OFF
-DWITH_TBB=ON
-DWITH_1394=OFF
-DWITH_OPENEXR=OFF
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0
-DCUDA_ARCH_BIN=6.2
-DCUDA_ARCH_PTX=""
-DINSTALL_C_EXAMPLES=ON
-DINSTALL_TESTS=ON
-DOPENCV_TEST_DATA_PATH=…/opencv_extra/testdata
…/

Consider using all 6 cores; sudo nvpmodel -m 2 or sudo nvpmodel -m 0

make -j4

You could also use our script to install opencv, though it is opencv 3.4.

https://github.com/AastaNV/JEP/blob/master/script/install_opencv3.4.0.sh

but there is some problems with gcc and cuda-8.0?