GCC version with CUDA

Today I updated my NVIDIA driver from 440xx to 450xx. As a consequence, I had to re-install CUDA and cudnn.

(I should also add that while reinstalling CUDA and cudnn I also updated them from 10.2 to 11 and 7 to 8 respectively)

I needed to add export PATH=/opt/cuda/bin:$PATH to my bashrc to be able to use nvcc - which is weird since nvcc worked before I updated my drivers and reinstalled CUDA and cudnn. (What might be happening here?)

But this created an issue - the gcc inside /opt/cuda/bin is gcc 9, whereas the system gcc is 10. I do not want to use gcc 9, I want to use gcc 10.

Before I updated my NVIDIA driver today and had to point bashrc to /opt/cuda/bin I was able to use both nvcc and gcc 10.

For completion’s sake, I checked which GCC versions are installed on my system -

[reik@reik-msi ~]$ pacman -Q | grep gcc
avr-gcc 10.2.0-1
gcc 10.2.0-1
gcc-fortran 10.2.0-1
gcc-libs 10.2.0-1
gcc7 7.5.0-2
gcc7-libs 7.5.0-2
gcc8 8.4.0-1
gcc8-libs 8.4.0-1
gcc9 9.3.0-3
gcc9-libs 9.3.0-3
lib32-gcc-libs 10.2.0-1

cuda won’t use gcc10.

https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#title-new-cuda-tools

The following new compilers are supported as host compilers for the CUDA compiler (nvcc)

Clang 9
GCC 9
PGI 20.1
ICC 19.1
Arm C/C++ 19.2

Thanks for the link!

Even if nvcc uses GCC 9 as the host compiler, I should still be able to use GCC 10 as my default system GCC version, as long as I have GCC 9 installed on my system.
Before I updated to CUDA 11, I was able to use GCC 10 as my default system GCC version with CUDA 10.2. CUDA 10.2 only supports GCC 8. Since I had GCC 8 installed on my system for nvcc to use as the host compiler, it didn’t matter that I was using GCC 10 as my default system GCC.

Manjaro is following Arch - for good (or bad) depending on point of view.

You can install gcc9 - it is available from the official repos.

What configurations you need to apply - if any - I have no idea - I haven’t got any knowledge of C.

I already have gcc9 installed, like I showed in the list in the original post.

Maybe I should rephrase my question -

The default version of GCC installed on my system (from pacman) is 10.
Earlier, I had CUDA 10.2 installed on my system and didn’t need to explicitly add /opt/cuda/bin to PATH to use nvcc. GCC was version 10 as expected.
Today I updated to CUDA 11 (also involved reinstalling optimus-switch if that is relevant). I had to add /opt/cuda/bin to PATH to use nvcc. /opt/cuda/bin contains gcc9, therefore the default GCC version is now 9.
I want to use nvcc as well as GCC 10.
(@steanne mentioned that CUDA won’t use GCC 10, but that is fine. I should still be able to use GCC 10 as my default system GCC version as long as I have GCC 9 installed on my system for nvcc to use as the default compiler)

The issue was that I had appended /opt/cuda/bin to the front of my $PATH, instead of to the end, giving it priority over /usr/bin.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.