Problems building latest headless CUDA on linux: can't find acceptable g++ version

Try building Blender with gcc 9 and CUDA with gcc 8.
For Blender, do the usual version switch to gcc 9. For Cuda, change the gcc version only in its CMakeCache.txt file.