How to solve CUDA incompatibility with high versions of GCC in Fedora

Jc Huynh
1 min readOct 14, 2022

--

If you are developing AI models using Nvidia GPU on the Linux distros such as Fedora with high-version GCC, there are times when you encounter the below error

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

A quick solution to solve this issue is to edit the host_config.h file in the CUDA library. However, this approach will not work most of the time.

Another solution is to downgrade your GCC version using spack.

In general, “Spack is a package management tool designed to support multiple versions and configurations of software on a wide variety of platforms and environments”.

Basically, Spack provides an easy way to build and use a lower version of gcc/g++ under your current environment.

Let me show you how easy it is to use spack.

Install Spack

git clone -c feature.manyFiles=true https://github.com/spack/spack.git

Activate spack environment

source spack/share/spack/setup-env.sh

List supported versions of GCC

spack info gcc

Install a specific GCC version such as 11.3.0

spack install gcc@11.3.0

Load installed GCC and check its version

spack load gcc@11.3.0
gcc --version

Hope you would see this message

gcc (Spack GCC) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Congratulations, you’ve just “downgraded” your GCC version to work better with the CUDA environment.

For more information on spack, please check its official site: https://spack.readthedocs.io/

--

--