Ubuntu 20.04 ships with gcc version 9 by default. However, cuda is only compatible with gcc up to version 8. We can expect this problem to get worse in the future, if cuda is not updated accordingly.
Solution
In the case of compiling with GPU=1, i.e. with using nvcc, fall back to a lower version of gcc.
The proposed change checks for the combination cuda + gcc-9 and prints an error if no older compiler is found (otherwise there will be an error by nvcc later in the make process).
In the case there is an older version installed on the system, it create a new hidden directory .bin_gcc, adds this to the front of the PATH variable inside the makefile and symlinks the older gcc version to .bin_gcc. This way, the older gcc version is preferred and compilation succeeds.
Testing
Different scenarios have been tested on Ubuntu workstations and servers.
Problem
Ubuntu 20.04 ships with
gcc
version 9 by default. However,cuda
is only compatible withgcc
up to version 8. We can expect this problem to get worse in the future, ifcuda
is not updated accordingly.Solution
In the case of compiling with
GPU=1
, i.e. with usingnvcc
, fall back to a lower version ofgcc
.The proposed change checks for the combination
cuda
+gcc-9
and prints an error if no older compiler is found (otherwise there will be an error bynvcc
later in the make process).In the case there is an older version installed on the system, it create a new hidden directory
.bin_gcc
, adds this to the front of thePATH
variable inside the makefile and symlinks the oldergcc
version to.bin_gcc
. This way, the oldergcc
version is preferred and compilation succeeds.Testing
Different scenarios have been tested on Ubuntu workstations and servers.
Â