As shown in the figure, the problem is that the gcc version is wrong and needs to be downgraded:
Solution:
gcc g++ downgrade
To test cuda, you need to downgrade the gcc and g++ versions (down to below 6.0).
ubuntu18.04 comes with gcc g++ 7.30
query mode:
gcc --version
g++ --version
Download the lower version of gcc g++ and set it up
sudo apt install gcc-4.8 g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70
In this way, you can switch between the gcc and g++ versions used by the following command:
sudo update-alternatives --config g++
sudo update-alternatives --config gcc