9

I tried to install CUDA on Fedora 31 but got stuck at the last step because CUDA officially supports Fedora 29 (gcc 8.2) while the version shipped with Fedora 31 is 9.2, I then installed Pytorch with CUDA support and without much surprise, CUDA support is not present:

>>> import torch
>>> device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
>>> device
device(type='cpu')

I then tried to search for gcc, g++ and gfortran on pkgs, but got stuck in a dependency hell, something like:

sudo dnf install gcc-8.2.1-2.fc29.x86_64.rpm gcc-gfortran-8.2.1-2.fc29.x86_64.rpm gcc-c++-8.2.1-2.fc29.x86_64.rpm -y

Error: 
 Problem 1: conflicting requests
  - nothing provides cpp = 8.2.1-2.fc29 needed by gcc-8.2.1-2.fc29.x86_64
  - nothing provides libgomp = 8.2.1-2.fc29 needed by gcc-8.2.1-2.fc29.x86_64
 Problem 2: conflicting requests
  - nothing provides libgfortran = 8.2.1-2.fc29 needed by gcc-gfortran-8.2.1-2.fc29.x86_64
  - nothing provides libquadmath = 8.2.1-2.fc29 needed by gcc-gfortran-8.2.1-2.fc29.x86_64
  - nothing provides libquadmath-devel = 8.2.1-2.fc29 needed by gcc-gfortran-8.2.1-2.fc29.x86_64
 Problem 3: conflicting requests
  - nothing provides libstdc++ = 8.2.1-2.fc29 needed by gcc-c++-8.2.1-2.fc29.x86_64
  - nothing provides libstdc++-devel = 8.2.1-2.fc29 needed by gcc-c++-8.2.1-2.fc29.x86_64

I found a bunch helpful links on this post but unfortunately the last version is gcc 7.3 My last option is building from source, but apart from that is there any other option? I'm not sure my computer can handle the compilation in a decent amount of time.

RMPR
  • 3,368
  • 4
  • 19
  • 31
  • Also ref. your comment here : https://stackoverflow.com/questions/47175706/how-to-install-gcc-4-9-2-on-rhel-7-4/47189915?noredirect=1#comment103990183_47189915 .... I can answer in a few days, I think. ... Are you quite sure that CUDA cannot use {gcc, g++, gfortran} version 9.2 ? – Knud Larsen Nov 14 '19 at 14:58
  • I didn't try because CUDA from negativo repo requires explicitely gcc 8.2 – RMPR Nov 14 '19 at 15:01
  • 1
    It is often easy to stand up a vm with a distro that includes the version of gcc and glibc you are targeting. – jww Nov 14 '19 at 16:23
  • This is a very good idea actually, I think I need to read about gpu passthrough – RMPR Nov 14 '19 at 18:23

3 Answers3

9

Build gcc-8.2.0

# dnf install gcc-c++ flex bison binutils-devel elfutils-devel elfutils-libelf-devel texinfo doxygen zlib-devel
tar xvf gcc-8.2.0.tar.xz 
cd gcc-8.2.0/
tar xvf mpfr-4.0.2.tar.xz && mv -v mpfr-4.0.2 mpfr
tar xvf gmp-6.1.2.tar.xz && mv -v gmp-6.1.2 gmp
tar xvf mpc-1.1.0.tar.gz && mv -v mpc-1.1.0 mpc
cd ../
mkdir build-gcc820
cd build-gcc820/
../gcc-8.2.0/configure --prefix=/usr/local/gcc82 --program-suffix=82 --enable-languages=c,c++,fortran --disable-multilib --disable-libstdcxx-pch --with-system-zlib
make 
# make install

Result : gcc82-c++-8.2.0-2.fc29.x86_64.rpm https://drive.google.com/file/d/1qGPvF9jc6CiI1a0-c3I4Zj4vxajEwSzc/view?usp=sharing Provides /usr/bin/{gcc8, g++8, gfortran8}

Install : # dnf install Downloads/gcc82-c++-8.2.0-2.fc29.x86_64.rpm

Knud Larsen
  • 5,753
  • 2
  • 14
  • 19
  • Thanks for this excellent solution. It worked for me a year or two ago but it failed today (kernel 5,17,5). It works after changing your ```configure``` line to this: ```./configure --prefix=/usr/local/gcc82 --program-suffix=82 --enable-languages=c,c++,fortran --disable-multilib --disable-libstdcxx-pch --enable-libstdcxx --with-system-zlib``` because the original was somehow trying to link to libstdc++v6, but it needs v3. See next comment for 2nd change ... – bliako Aug 03 '22 at 23:04
  • ... continuing from previous comment: The *2nd change* is to change line 317 of ```gcc-8.2.0/libsanitizer/sanitizer_common/sanitizer_internal_defs.h``` ... tbc ... change line 317 from ```typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]``` to ```typedef char IMPL_PASTE(assertion_failed_##_, line)[(2*(int)(pred)-1)<0?1:(2*(int)(pred)-1)]``` (as it was failing an assertion about possible negative or zero size array. There is a 3rd change which is quite drastic and dangerous. See next comment for 3rd change... – bliako Aug 03 '22 at 23:07
  • The *3rd change* is the most dangerous as it involves replacing the linux kernel header file: ```/usr/include/linux/cyclades.h``` with one from an earlier kernel because since 2021 they have removed the header ```cyclades.h``` from linux kernel headers. Alas, ```libsanitizer/``` in gcc8.2 (and I guess all previous versions and some more recent) includes for whatever reason the header specific to some obsolete hardware. ```https://github.com/OpenChannelSSD/linux/tree/master/include``` contains the *2* instances of cyclades.h which need to be copied to 2 places in ```/usr/include/linux``` tbc.. – bliako Aug 03 '22 at 23:23
  • ... continued from previous comment. Note that there are 2 ```cyclades.h``` files to be copied under ```/usr/include/linux```. After hopefully successful compilation of gcc8.2 one can reinstate the entire contents of ```/usr/include/linux``` by reinstalling with system's package manager (e.g. ```dnf reinstall kernel-headers.x86_64```). That said, the best solution would be to remove the ```cyclades.h``` dependency from ```libsanitizer``` (see the header file above) and there may be solutions already out there because there are a lot of hurt OAP softwares in need of a fix... to be continued .. – bliako Aug 03 '22 at 23:28
  • ... continued from previous comment. The reason I need to install an older version of GCC in my system (which currently defaults to gcc 12!) is because I need to install NVIDIA's CUDA toolkit version 10.2 and nothing newer because of my older GPU. Therefore I need gcc82 which is compatible with that specific cuda version. I guess we are quite a few out there with this requirement. Thanks again for your excellent solution, which unfortunately was beaten by the sanitizer hehe :) – bliako Aug 03 '22 at 23:31
2

You can use one of the 3rd-party repo-agnostic package collections, such as Nixpkgs, Homebrew On Linux, or pkgsrc.

Out of these, I recommend avoiding Nixpkgs, because it tries to isolate you from libraries installed outside of itself, which sometimes makes sense (reproducible builds), but creates extra work for users in common scenarios.

I choose to use Homebrew On Linux for myself. First I installed Homebrew according to instructions on the site, and then

$ brew install 'gcc@10'
   [... installing ...]
$ which gcc-10
/home/linuxbrew/.linuxbrew/bin/gcc-10

Done, gcc-10 is available to me.

user7610
  • 25,267
  • 15
  • 124
  • 150
0

Offline GCC4.4.4 installation

How to install GCC4.4.4 or GCC444 by replace the new version using RMP package?

  • GCC444 RMP dependence and order of input file.
  • then:
sudo rpm -ivh --force gcc-4.4.4-2.fc13.x86_64.rpm gmp-4.3.1-6.fc13.x86_64.rpm gmp-devel-4.3.1-6.fc13.x86_64.rpm gcc-c++-4.4.4-2.fc13.x86_64.rpm cloog-ppl-0.15.7-1.fc12.x86_64.rpm cpp-4.4.4-2.fc13.x86_64.rpm glibc-2.12-1.x86_64.rpm glibc-common-2.12-1.x86_64.rpm glibc-devel-2.12-1.x86_64.rpmglibc-headers-2.12-1.x86_64.rpm kernel-headers-2.6.33.3-85.fc13.x86_64.rpm libgcc-4.4.4-2.fc13.x86_64.rpm libstdc++-4.4.4-2.fc13.x86_64.rpm libstdc++-devel-4.4.4-2.fc13.x86_64.rpm libgomp-4.4.4-2.fc13.x86_64.rpm mpfr-2.4.2-1.fc13.x86_64.rpm ppl-0.10.2-10.fc12.x86_64.rpm

You should have an output such as:

    warning: gcc-4.4.4-2.fc13.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID e8e                40fde: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:libgcc-4.4.4-2.fc13              ################################# [  6%]
       2:glibc-common-2.12-1              ################################# [ 12%]
       3:glibc-2.12-1                     warning: /etc/localtime created as /etc/lo                caltime.rpmnew
    warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
    ################################# [ 18%]
       4:libstdc++-4.4.4-2.fc13           ################################# [ 24%]
       5:gmp-4.3.1-6.fc13                 ################################# [ 29%]
       6:mpfr-2.4.2-1.fc13                ################################# [ 35%]
       7:cpp-4.4.4-2.fc13                 ################################# [ 41%]
       8:ppl-0.10.2-10.fc12               ################################# [ 47%]
       9:cloog-ppl-0.15.7-1.fc12          ################################# [ 53%]
      10:libstdc++-devel-4.4.4-2.fc13     ################################# [ 59%]
      11:libgomp-4.4.4-2.fc13             ################################# [ 65%]
      12:kernel-headers-2.6.33.3-85.fc13  ################################# [ 71%]
      13:glibc-headers-2.12-1             ################################# [ 76%]
      14:glibc-devel-2.12-1               ################################# [ 82%]
      15:gcc-4.4.4-2.fc13                 ################################# [ 88%]
      16:gcc-c++-4.4.4-2.fc13             ################################# [ 94%]
      17:gmp-devel-4.3.1-6.fc13           ################################# [100%]

You can assert you have what is expected with:

gcc --version

That gives:

    gcc (GCC) 4.4.4 20100503 (Red Hat 4.4.4-2)
    Copyright (C) 2010 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.
xiawi
  • 1,772
  • 4
  • 19
  • 21