What Do I Do If a Compilation Error Is Reported Indicating that the CUDA and GCC Versions Do Not Match When Ubuntu 20.04 Is Used to Install the Caffe Environment?
Symptom
When Ubuntu 20.04 is used to install the Caffe environment, a compilation error similar to the following is reported:
/usr/local/cuda-10.0/include/crt/host_config.h:129:2: error: #error --unsupported GNU version! Gcc versions later than7 are not supported!
Possible Cause
The default GCC version of Ubuntu 20.04 is GCC 9. If CUDA 10.0 is used, a message is displayed indicating that versions later than GCC 7 are not supported because CUDA 10.0 matches GCC 7 only. In this case, you need to downgrade the default GCC version.
Solution
Install GCC of an earlier version (for example, GCC 7) and link it to the installation directory of the CUDA bin file. This ensures that the correct GCC version can be found during CUDA compilation when both GCC 7 and GCC 9 are installed in the environment. /usr/local/cuda-10.0 in the following is only an example. Replace it with the actual CUDA installation path.
sudo apt-get install g++-7 -y sudo ln -s /usr/bin/gcc-7 /usr/local/cuda-10.0/bin/gcc sudo ln -s /usr/bin/g++-7 /usr/local/cuda-10.0/bin/g++