How-to: Building CUDA 12.9 on Fedora 44 with GCC 14 (GTX 1050 / Pascal)

I recently managed to build and run NVIDIA CUDA 12.9 Samples on Fedora 44 with a GTX 1050 (Pascal, compute capability 6.1).

Note: Why only install CUDA 12.9, cause that, my architecture not supports CUDA 13.x, so the article may also be useful for architecture in Volta, Pascal, Maxwell
which also not supports CUDA 13.x.
For the supporting matrix, check it here: cuda-toolkit-driver-and-architecture-matrix

Since Fedora 44 ships with GCC 16, which is newer than the maximum GCC version supported by CUDA 12.9, I ran into several compatibility issues.

I’m sharing my experience here in case anyone else is trying to use CUDA 12.9 on Fedora 44, particularly with an older NVIDIA GPU.

1. System information

Component Version
OS Fedora Linux 44 (x86_64)
Kernel 7.2.11-200.fc44.x86_64
GPU NVIDIA GeForce GTX 1050 (Pascal, SM 6.1)
NVIDIA Driver 580.178.04
CUDA Toolkit 12.9.2
System GCC 16.2.1
Compatibility GCC 14.3.1
glibc 2.43
CMake 4.3.0

I used the CUDA Samples v12.9 repository (commit cab7c66) for test.

2. The GCC compatibility issue

CUDA 12.9 supports GCC versions up to GCC 14. However, Fedora 44 ships with GCC 16 by default.

Attempting to compile CUDA code with the system compiler results in:

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

Although NVCC provides the -allow-unsupported-compiler option, I preferred to use a supported compiler rather than bypass the version check.

I initially tried using Clang 18 as the CUDA host compiler, but encountered additional issues with OpenMP detection and header compatibility because the installed libomp-devel package belonged to LLVM 22.

Eventually, I decided to use GCC 14 instead.

3. Installing GCC 14 from Fedora Koji

Interestingly, although GCC 14 is not available through my Fedora 44 DNF repositories:

sudo dnf install gcc14 gcc14-c++

DNF reports:

No match for argument: gcc14
No match for argument: gcc14-c++

So that to say, you need to compile gcc from source?
No. I found that Fedora Koji actually has a completed Fedora 44 build:

gcc14-14.3.1-1.fc44.1

You can check it here

If you want to search for other compatible gcc(g++), you can go Fedora Koji

Instead of compiling GCC 14 from source or installing packages from another distribution, I downloaded the Fedora 44 RPMs directly from Koji.

Also you can download rpm package from the website above

First, install the Koji client:

sudo dnf install koji

Then download the build:

mkdir -p ~/Downloads/gcc14
cd ~/Downloads/gcc14

koji download-build --arch=x86_64 \
  gcc14-14.3.1-1.fc44.1

Install the two required packages:

sudo dnf install \
  ./gcc14-14.3.1-1.fc44.1.x86_64.rpm \
  ./gcc14-c++-14.3.1-1.fc44.1.x86_64.rpm

In my case, DNF resolved the dependencies without requiring any package removals or downgrades.

GCC 14 can coexist with the system GCC 16, so there is no need to replace the default compiler.

4. glibc compatibility

I also encountered compatibility issues between CUDA 12.9 and the newer glibc headers provided by Fedora 44.

I resolved these using a patch from Gentoo community before proceeding with the CUDA Samples build.

This is a separate issue from GCC version compatibility: installing GCC 14 alone does not necessarily resolve incompatibilities between CUDA headers and newer glibc headers.

Then you could apply it like this(you should have installed cuda)

cd /usr/local/cuda/include
sudo patch -p1 --dry-run < /path/to/your/patch # for test
sudo patch -p1 < /path/to/your/patch

5. Configuring CUDA Samples with GCC 14

Clone the CUDA Samples repository and check out the CUDA 12.9 release:

git clone https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples
git checkout v12.9

Configure the project:

cmake -S . -B build \
  -DCMAKE_C_COMPILER="$(command -v gcc-14)" \
  -DCMAKE_CXX_COMPILER="$(command -v g++-14)" \
  -DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.9/bin/nvcc \
  -DCMAKE_CUDA_HOST_COMPILER="$(command -v g++-14)" \
  -DCMAKE_CUDA_ARCHITECTURES=61

The 61 architecture corresponds to the GTX 1050 (Pascal).

For other GPUs, this value should be adjusted accordingly.

You can check it like this:

nvidia-smi --query-gpu=compute_cap
# output:
# compute_cap
# 6.1

The output value without dot is the value needed.

6. NVCC still selecting GCC 16

Even after successfully configuring CMake with GCC 14, I encountered another issue during compilation:

Building CUDA fatbin:
Samples/0_Introduction/matrixMulDrv/matrixMul_kernel64.fatbin

The build failed with:

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

The important detail is that setting CMAKE_CUDA_HOST_COMPILER does not necessarily affect every custom NVCC invocation in the project.

In particular, custom commands generating CUDA fatbins may invoke NVCC independently.

To ensure that NVCC uses GCC 14, I used the following compiler selection:

export NVCC_CCBIN="$(command -v g++-14)"

You can also add it to your ~/.bashrc for persistence.

Then rebuilt the project:

cmake --build build -j"$(nproc)"

7. Test results

After resolving the compilation issues, I successfully built the CUDA Samples and ran the provided tests.

python3 ./run_tests.py --dir ./build/Samples --config test_args.json --output ./test --parallel 8

My test summary was:

Test Summary:
Ran 193 test runs for 180 executables.
Failed runs (10):
  dmmaTensorCoreGemm : Failed (code 2)
  cudaCompressibleMemory : Failed (code 2)
  bf16TensorCoreGemm : Failed (code 2)
  cudaTensorCoreGemm : Failed (code 2)
  globalToShmemAsyncCopy : Failed (code 2)
  tf32TensorCoreGemm : Failed (code 2)
  immaTensorCoreGemm : Failed (code 2)
  LargeKernelParameter : Failed (code 1)
  simpleAWBarrier : Failed (code 2)
  simpleAttributes : Failed (code 2)

The output reports 10 failed runs, although only nine entries appear in the displayed failure list.

Most of the listed failures involve features that require newer GPU architectures, such as Tensor Cores or asynchronous memory operations.

Since the GTX 1050 is a Pascal GPU (SM 6.1), these failures are not entirely unexpected. However, the individual logs would need to be examined before attributing every failure to hardware limitations.

The important result is that CUDA 12.9 Samples could be built and most of the executed tests completed successfully on this setup.

8. Conclusion

For anyone trying to use CUDA 12.9 on Fedora 44 with an older NVIDIA GPU:

  • GCC 16 is newer than the officially supported host compiler versions for CUDA 12.9.
  • Fedora Koji has a GCC 14 build for Fedora 44, even though it is not available through my enabled DNF repositories.
  • GCC 14 can coexist with the system GCC 16 without replacing it.
  • Explicitly configure both the C/C++ compilers and the CUDA host compiler in CMake.
  • Be aware that custom NVCC commands may require additional host compiler configuration.
  • Newer glibc headers may require separate compatibility fixes.
  • Some CUDA Samples require GPU features unavailable on Pascal hardware.

This setup worked for my GTX 1050 with NVIDIA Driver 580 and CUDA Toolkit 12.9.

Hopefully, these notes will save someone else some time when setting up CUDA on a newer Fedora release.

References

Good work getting this all working, and thanks for writing up how you did it so comprehensively.

An alternative method could have been using toolbx, where you could have created a toolbx container with an older distro release, containing glibc and gcc versions which CUDA 12.9 expected.

If you need to keep this running in the future that might be an easier route, if you end up needing more glibc patches / similar workarounds.

Thanks for the suggestion! I appreciate you pointing out the toolbx route!
May in the next release, when I found newer fedora version not work fine with cuda, I will switch to the toolbx way.