Wrong GCC version For CUDA (Linux) -- How to solve

While using a Blender I built on Linux (Kubuntu 19.04 Eoan Ermine), I ran into a strange problem when I tried to do a GPU CUDA render: the render failed and the console told me I had the wrong version of gcc installed. This strange bug only occurs after Blender is built.

I want to share the solution I found for the problem:
First, make sure you have the right version of gcc and g++ installed:
sudo apt install gcc-8 g++-8
then follow the instructions here: Ubuntu 16.04: `unsupported GNU version! gcc versions later than 4.9 are not supported!` · Issue #246 · NervanaSystems/neon · GitHub
(He’s using an even older version of gcc and cuda, make sure to change the numbers like I did here)

sudo ln -s /usr/bin/gcc-8 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-8 /usr/local/cuda/bin/g++

What does this do? This creates a symbolic link in cuda’s binary directory that tells it to use gcc-8 instead of gcc and g++-8 instead of g++. cuda searches its bin for “gcc” and “g++”, but the files are actually linked to “gcc-8” and “g++-8” instead. No need to change cuda’s config files.

I don’t know if this will work for everyone that runs into this issue, but it was easy and worked for me.

I hope this helps someone :smiley:

On a related note-- should there be a compiler warning or something? Is it normal to need to have cuda installed to the system to compile the render kernels? I would like to understand more why I had this problem.

2 Likes