Because of program compatibility issues I need to downgrade GCC to at least 4.9

How do I do this? Thanks.

EDIT: The program is Blender and am trying to do GPU rendering. The specific error the console is kicking out is

CUDA version 7.5 detected, build may succeed but only CUDA 6.5 is officially supported.
Compiling CUDA kernel ...
"/usr/local/cuda/bin/nvcc" -arch=sm_52 -m64 --cubin "/usr/share/blender/2.76/scripts/addons/cycles/kernel/kernels/cuda/kernel.cu" -o "/home/matthew/.config/blender/2.76/cache/cycles_kernel_sm52_3A157B804910758CA7C526B5EF063D78.cubin" --ptxas-options="-v" --use_fast_math -I"/usr/share/blender/2.76/scripts/addons/cycles/kernel" -DNVCC -D__KERNEL_CUDA_VERSION__=75
In file included from /usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:76:0,
                 from <command-line>:0:
/usr/local/cuda/bin/../targets/x86_64-linux/include/host_config.h:115:2: error: #error -- unsupported GNU version! gcc versions later than 4.9 are not supported!
 #error -- unsupported GNU version! gcc versions later than 4.9 are not supporte
CUDA kernel compilation failed, see console for details.

Refer to the Cycles GPU rendering documentation for possible solutions:

Error: CUDA kernel compilation failed, see console for details.`
  • Did you try sudo apt-get install gcc-4.9? – muru Jan 24 '16 at 2:13
  • (And then compile your programs with gcc-4.9 instead of just gcc.) – fkraiem Jan 24 '16 at 2:35
  • 1
    Already did, says gcc-4.9 is already the newest version However doing gcc -v or gcc --version still says 5.2.1 – Mattr567 Jan 24 '16 at 2:57
  • Installing gcc-4.x doesn't 'downgrade' gcc in the sense you are probably thinking, it just installs it as a separate executable. So unless you symlink it (or use the update-alternatives mechanism) you will need to invoke the alternate version explicitly as gcc-4.9 like @fkraiem said. If your program uses a make, one way may be to pass a CC=/usr/bin/gcc-4.9 on the command line - tell us more about your program and we may be able to give more detailed advice. – steeldriver Jan 24 '16 at 3:32
  • 1
    What steps (commands) are you using to build it? Did you try export CC=/usr/bin/gcc-4.9 and/or export CXX=/usr/bin/g++-4.9 at the start? – steeldriver Jan 24 '16 at 13:06

Like @steeldriver suggests, you need to use update-alternatives. Exactly step 3 on this question. Since at this point 4.9 is 4.9.3, which is not supported, you'll need 4.8.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 --slave /usr/bin/g++ g++ /usr/bin/g++-5

Remember to choose gcc-4.8 before running the installer:

sudo update-alternatives --config gcc

and after, to switch back to having gcc-5 by default.

(Since you're doing it to install the CUDA SDK, I'll add that if you want to test the samples, you may want to read this.)


THIS ANSWER IS DANGEROUS as it can damage your system and the GCC libraries on your system and make your system unusable. **Exercise caution when using this answer, and consider this a 'last resort' answer.

Uninstall gcc5.4

sudo apt-get remove gcc g++

Check gcc again:

gcc –version

Install gcc 4.9/g++ 4.9

sudo apt-get install gcc-4.9 g++-4.9

Checking Version:

g++-4.9 –version

Link to gcc g++

ln -s /usr/bin/g++-4.9 /usr/bin/g++
ln -s /usr/bin/gcc-4.9 /usr/bin/gcc

Checking Version:

g++ –v
gcc –v

cited from this blog, and my own install

  • 4
    This is a terrible advice – Atinesh Mar 8 '19 at 10:00
  • Well I read the comment after running the code. Damn my system is screwed now. – Yash Kumar Atri Jan 14 '20 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.