【问题标题】:How to install an older version of gcc on Fedora如何在 Fedora 上安装旧版本的 gcc
【发布时间】:2019-11-14 14:26:54
【问题描述】:

我尝试在 Fedora 31 上安装 CUDA,但在最后一步卡住了,因为 CUDA 正式支持 Fedora 29 (gcc 8.2),而 Fedora 31 附带的版本是 9.2,然后我安装了支持 CUDA 的 Pytorch,毫无意外, CUDA 支持不存在:

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

然后我尝试在pkgs 上搜索 gcc、g++ 和 gfortran,但陷入了依赖地狱,例如:

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

我在this post 上找到了一堆有用的链接,但不幸的是最后一个版本是 gcc 7.3 我的最后一个选择是从源代码构建,但除此之外还有其他选择吗?我不确定我的计算机能否在相当长的时间内完成编译。

【问题讨论】:

  • 也参考。您在这里的评论:stackoverflow.com/questions/47175706/… .... 我想我可以在几天内回答。 ...您确定 CUDA 不能使用 {gcc, g++, gfortran} 9.2 版吗?
  • 我没有尝试,因为来自 negativo repo 的 CUDA 明确需要 gcc 8.2
  • 使用包含您所针对的 gcc 和 glibc 版本的发行版建立一个 vm 通常很容易。
  • 其实这是一个非常好的主意,我想我需要阅读一下gpu passthrough

标签: python-3.x linux gcc pytorch


【解决方案1】:

构建 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

结果:gcc82-c++-8.2.0-2.fc29.x86_64.rpmhttps://drive.google.com/file/d/1qGPvF9jc6CiI1a0-c3I4Zj4vxajEwSzc/view?usp=sharing 提供/usr/bin/{gcc8, g++8, gfortran8}

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

【讨论】:

    【解决方案2】:

    离线GCC4.4.4安装

    如何通过RMP包替换新版本来安装GCC4.4.4或GCC444?

    • GCC444 RMP 依赖和输入文件的顺序。
    • 然后:
    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
    

    你应该有这样的输出:

        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%]
    

    你可以断言你有预期的东西:

    gcc --version
    

    这给了:

        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.
    

    【讨论】:

      【解决方案3】:

      您可以使用与第三方存储库无关的软件包集合之一,例如 NixpkgsHomebrew On Linuxpkgsrc

      其中,我建议避免使用 Nixpkgs,因为它试图将您与安装在其外部的库隔离开来,这有时是有意义的(可重现的构建),但在常见情况下会为用户带来额外的工作。

      我自己选择在 Linux 上使用 Homebrew。首先我按照网站上的说明安装了 Homebrew,然后

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

      完成,我可以使用gcc-10

      【讨论】:

        猜你喜欢
        • 2023-03-16
        • 1970-01-01
        • 2011-12-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多