8

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:
http://www.blender.org/manual/render/cycles/gpu_rendering.html

Error: CUDA kernel compilation failed, see console for details.`
steeldriver
  • 131,985
  • 21
  • 239
  • 326
Mattr567
  • 81
  • 1
  • 1
  • 4
  • Did you try `sudo apt-get install gcc-4.9`? – muru Jan 24 '16 at 02:13
  • (And then compile your programs with `gcc-4.9` instead of just `gcc`.) – fkraiem Jan 24 '16 at 02: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 02: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 03:32
  • Its Blender. I am trying to enable CUDA rendering. I have the CUDA tookit 7.5 and the proprietary nvidia driver version 352.68. I have added the error the console is kicking out. – Mattr567 Jan 24 '16 at 04:50
  • 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
  • Possible duplicate of [CUDA 6.5 complains about not supporting gcc 4.9 - what to do?](http://stackoverflow.com/questions/28009785/cuda-6-5-complains-about-not-supporting-gcc-4-9-what-to-do) – bain Jan 24 '16 at 13:13
  • Tried `export CC=/usr/bin/gcc-4.9`and `export CXX=/usr/bin/g++-4.9` but blender still complains even when I resinstall it. From looking at the other thread @bain posted I have to tell CUDA to use 4.9 since it is already installed. Looking at the thread I have to do `nvcc --compiler-bindir /usr/bin/gcc-4.9` + some other stuff not specified, but what else do I have to do, otherwise without it, it just outputs `nvcc fatal : No input files specified; use option --help for more information` – Mattr567 Jan 24 '16 at 20:25
  • The error comes from the file `/usr/local/cuda/bin/../targets/x86_64-linux/include/host_config.h`, look in there to see what tests determine the gcc version so you may get an idea of the env variable to set. – sambler Jan 25 '16 at 01:58
  • Found it, it says: `#if defined(__GNUC__)` `#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9)` `#error -- unsupported GNU version! gcc versions later than 4.9 are not supported!` – Mattr567 Jan 25 '16 at 02:13

2 Answers2

6

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.)

ira
  • 61
  • 1
  • 2
1

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

Thomas Ward
  • 72,494
  • 30
  • 173
  • 237
Jayhello
  • 191
  • 2