1

I have installed the cuda-samples-8-0 package on Ubuntu 17.04, and I will would like to build the samples with gcc-5, which I have installed along gcc-6 on my machine. gcc-6` is not supported by CUDA 8 and gives numerous compilation errors.

How to get make to use gcc-5?

I have tried sudo make CXX=g++-5 CC=gcc-5 from the /usr/local/cuda-8.0/samples directory which still leads to gcc-6 being used.

#error -- unsupported GNU version! gcc versions later than 5 are not supported!

  ^~~~~
Imran
  • 12,950
  • 8
  • 64
  • 79
  • 1
    There is nvcc option of `-ccbin` to select good compiler. But there is no env string to make the selection of correct gcc global: https://stackoverflow.com/a/44792397 Or try to comment out the error-generating pragma: https://github.com/BVLC/caffe/wiki/GeForce-GTX-1080,---CUDA-8.0,---Ubuntu-16.04,---Caffe Also check https://stackoverflow.com/questions/6622454 – osgx Jul 15 '17 at 21:47

2 Answers2

3

Messing up with the links can result in unwanted problems. For eg. I couldn't compile programs because they were meant for g++-7/gcc-7. I suggest using

cmake -DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5 ..

as it will not mess with your symlinks.

markroxor
  • 5,928
  • 2
  • 34
  • 43
  • Thank you. I was trying to follow https://stackoverflow.com/questions/6622454/cuda-incompatible-with-my-gcc-version but it wasnt working how I wanted. Your recommendation helped me install gpu support with xgboost – MikeDoho Jul 24 '18 at 02:44
2

I just got this to work by symlinking /usr/bin/gcc-5 to /usr/local/cuda-8.0/bin/gcc and /usr/bin/g++-5 to /usr/local/cuda-8.0/bin/g++:

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

And I also had to follow this answer after getting the error /usr/bin/ld: cannot find -lnvcuvid

Imran
  • 12,950
  • 8
  • 64
  • 79