-
Improvement
-
Resolution: Superseded
-
Normal
-
None
-
None
CUDA 9.1 requires the following changes to be used with gcc versions > 6
https://carterturn.com/h/Guides/NVIDIA%20CUDA%209.1%20with%20GCC%207.2
After updating my system to Fedora 27, I was pleased to find that I had a shiny new GCC version, GCC 7.2.1 (I enjoy new compilers too much). Unfortuntely, the most recent version of NVIDIA's CUDA, CUDA 9.1, which I also enjoy using, is only compatible with GCC 6. Here, I will document my workaround for this, which allows one to use most (seems like all) of CUDA's features with GCC 7.2.1.
CUDA 9.1First, install CUDA 9.1. When installing, add the --override flag to the installer and say yes when it asks to install in an unsupported configuration (that is the entire point of this, right?).
Modify host_config.h
As usual, we need to comment out the section of NVIDIA's host_config.h that prevents us from using newer GCC versions. In a slight twist from last time, we need to modify /usr/local/cuda/include/crt/host_config.h (Note that the /usr/local/cuda part depends on where you chose to install during the installation). Comment out the line#error – unsupported GNU version! gcc versions later than 6 are not supported!For me, that was line 121.
Modify floatn.h
For some reason, nvcc does not like 128 bit floats, so we need to modify /usr/include/bits/floatn.h. The easiest way to do this (e.g. the way that involves opening as few files as possible) is to add#ifdef _CUDACC_ #define __HAVE_FLOAT128 0 #endifjust after the section of floatn.h that defines __HAVE_FLOAT128. In my copy, this was line 37.
So far, the only error I am getting is related to having an outdated driver, so I think this works.