The question is about a specific combination of versions but is relevant more generally.

I've just dist-upgraded from Kubuntu 12.04 to 14.04. Now, when I want to compile CUDA code (with CUDA 6.5), I get:

#error -- unsupported GNU version! gcc 4.9 and up are not supported!

I installed gcc-4.8 (and 4.7), and tried to use the symlinks-in-/usr/local/cuda/bin solution suggested here:

CUDA incompatible with my gcc version

but this doesn't work. What should I do?

share|improve this question
up vote 18 down vote accepted

This solution is relevant to multiple combinations of CUDA and GCC versions.


You can tell CUDA's nvcc to use a specific version of gcc. So, suppose you want gcc 4.7 for use with CUDA 6. You run:

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

and then add the following switch to your nvcc command-line:

nvcc --compiler-bindir /usr/bin/gcc-4.7  # rest of the command line here

If you're building with CMake, add an appropriate setting before looking for CUDA to your CMakeLists.txt, e.g.:

set(CUDA_HOST_COMPILER /usr/bin/gcc-4.7)  # -> ADD THIS LINE <-
find_package(CUDA)

Also, it seems clang can compile CUDA as well, maybe that's worth experimenting with (although you would have to build it appropriately).

Note: Some Linux (or other OS) distributions don't have packages for multiple versions of gcc (in the same release of the OS distribution). I would advise against trying to install a package from another release of the distribution on an older release, and consider building gcc instead. That's not entirely trivial but it is quite doable - and of course, it's your only option if you don't have root access to your machine.

share|improve this answer

Switch back to a supported config. They are listed in the getting started document for any recent CUDA distribution.

For your particular configuration you have currently listed, you might have better luck with CUDA 7 RC, which is now available to registered developers.

share|improve this answer
1  
I can't remove gcc 4.9 from my system, or downgrade the distro for something as minor as this... – einpoklum Jan 18 '15 at 16:08
1  
I switched to 7 which is really working well and it has support for 4.9. Though you might need to update to ubuntu 14.10. Also it has c++11 which is great. – flip Jan 19 '15 at 15:22

I had a similar issue with CUDA Toolkit 7.5 and gcc 5.2.1.

I did modify the host_config.h file in /usr/local/cuda/include/:

Just remove the lines where it check the gcc version. It did solve my problem.

Credits goes to Darren Garvey (https://groups.google.com/forum/#!topic/torch7/WaNmWZqMnzw)

share|improve this answer
    
There weren't any side affects that you saw from doing this, were there? – Jacob Holloway Apr 14 '16 at 18:14
    
I didn't notice anything. Everything seems working fine – Conchylicultor Apr 14 '16 at 23:50
    
@Conchylicultor: There are multiple known incompatibilities between CUDA 7.x and GCC 5.x . It would be unwise to remove the version check. – einpoklum Dec 4 '16 at 23:13
    
@einpoklum Probably, I suppose they put this limit for a reason but this hack worked perfectly for me. Just out of curiosity, what are the incompatibilities for instance ? – Conchylicultor Dec 5 '16 at 1:01
    
Mysterious compilation failures with certain standard library constructs; weird linking trouble which I forget the details of since I didn't file a bug about them. – einpoklum Jan 6 '17 at 18:10

Very often you will find that CUDA has had newer releases by the time you encounter this problem. For example, the original formulation of the question was about CUDA 6 and GCC 4.9; CUDA 7 supported GCC 4.9. CUDA 8 supports GCC 5.x . And so on.

share|improve this answer
    
I have Cuda7.5 and got the same error as question for Caffe! – Mona Jalal Aug 23 '16 at 21:14
    
Quite unlikely. Perhaps you got a similar error for a newer version of gcc? CUDA 7.5 supports gcc 4.9, but does not support gcc 5.x – einpoklum Aug 23 '16 at 21:15
    
Well, I had GCC 5.x and was trying to say I have the same error – Mona Jalal Aug 23 '16 at 22:46
    
@MonaJalal: Time to upgrade to CUDA 8 then. – einpoklum Dec 4 '16 at 23:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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