深度学习微软 azure-云服务器组 centos特殊内核版本 gpu NVIDIA 驱动及CUDA 11.0安装

深度学习微软 azure-云服务器组 centos特殊内核版本 gpu NVIDIA 驱动及CUDA 11.0安装

以前写过篇ubuntu装驱动的,这次是centos相关

首先感慨azure的gpu服务器实在是太贵了

技术支持应该也一般,算法团队一直搞不定显卡驱动的问题,和azure客服扯皮,项目进度缓慢,个人协助解决

通常一般公司自已维护的机房服务器,系统都是官方的发行版,兼容性问题会少些

而云服务商,有些云服务器环境,os并不是centos/debian等官方的发行版

而可能是其自已编译的版本,个人技术和认知有限,猜测是加一些新的特性好管理什么的,但这种特化的os环境,就会有一些兼容性问题

非azure的其他深度学习gpu环境,个人不太清楚,这个例子是azure

最后完美解决了,个人也是第一次遇到这种问题,会附安装命令,主要是内核版本不一致的问题

现在说起来简单,但定位问题花了不少工夫,其实定位到是内核原因,解决的路线和思路就有了

但一开始怎么也没想到会是内核的问题

首先说下显卡驱动不好安装的原因

选择的是centos的服务器,azure的服务器组,centos大版本一样,但内核是微软自已编译的内核,所以按NVIDIA官方向导,和其他资料,因为内核版本不一致,会出现些问题

装显卡驱动及cuda是需要gcc本地编译的,而编译又依赖内核相关的基础包(lib之类)

yum install kernel-devel

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, langpacks, nvidia
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: ftp.sjtu.edu.cn
 * centos-sclo-sclo: ftp.sjtu.edu.cn
 * epel: mirrors.bestthaihost.com
Package kernel-devel-3.10.0-1127.13.1.el7.x86_64 already installed and latest version
Nothing to do
[root@b2b-qa-cne2-goldradar-etlgpu-0 cdp]# uname -r
3.10.0-1062.12.1.el7.x86_64

发现没有 这就是azure服务器深度学习gpu驱动,cuda安装失败的问题所在,系统的内核为3.10.0-1062.12.1.el7.x86_64,但是系统里自带的,及yum安装的是 kernel-devel-3.10.0-1127.13.1.el7.x86_64

版本对不上,装驱动时编译不过,能安装成功才是怪事


安装命令

  • 首先确认内核版本,确定匹配再执行后续操作

    uname -r
    3.10.0-1062.12.1.el7.x86_64

  • 准备操作的临时备份目录

mkdir gpu_tmp
cd gpu_tmp
sudo su

  • 下载和内核实际版本匹配的kernel-headers,kernel-devel包,下载驱动包,找驱动的方式见之前ubuntu装驱动的文章

wget http://repo.iotti.biz/CentOS/7/x86_64/kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm

wget http://repo.iotti.biz/CentOS/7/x86_64/kernel-devel-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm

wget http://cn.download.nvidia.com/tesla/450.51.06/NVIDIA-Linux-x86_64-450.51.06.run

  • 默认命令安装的kernel-devel,kernel-headers和内核不匹配,移除旧的,再安装和内核匹配的rpm包

yum remove kernel-devel.x86_64

rpm -Uvh kernel-devel-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm

yum remove kernel-headers.x86_64

rpm -Uvh kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm

  • 内核已准备好后,指定内核地址,安装编译驱动(驱动安装需要本地编译)

yum install centos-release-scl

yum install devtoolset-9

scl enable devtoolset-9 bash

sh NVIDIA-Linux-x86_64-450.51.06.run --kernel-source-path /usr/src/kernels/3.10.0-1062.12.1.el7.centos.plus.x86_64/

nvidia-smi

成功后结果如下

NVIDIA Accelerated Graphics Driver

Screen Shot 2020-07-29 at 6.15.11 PM


安装排查的一些补充细节

查看系统信息

uname -m && cat /etc/*release

x86_64
CentOS Linux release 7.7.1908 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
CentOS Linux release 7.7.1908 (Core)
CentOS Linux release 7.7.1908 (Core)

CUDA-Enabled Testa Products

安装GCC

yum install gcc

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, langpacks, nvidia
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                                                           
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-39.el7 will be installed
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-39.el7.x86_64
--> Running transaction check
---> Package glibc-devel.x86_64 0:2.17-307.el7.1 will be installed
--> Processing Dependency: glibc-headers = 2.17-307.el7.1 for package: glibc-devel-2.17-307.el7.1.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-307.el7.1.x86_64
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.17-307.el7.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================================================================
 Package                                            Arch                                        Version                                               Repository                                 Size
======================================================================================================================================================================================================
Installing:
 gcc                                                x86_64                                      4.8.5-39.el7                                          base                                       16 M
Installing for dependencies:
 glibc-devel                                        x86_64                                      2.17-307.el7.1                                        base                                      1.1 M
 glibc-headers                                      x86_64                                      2.17-307.el7.1                                        base                                      689 k

Transaction Summary
======================================================================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 18 M
Installed size: 41 M
Is this ok [y/d/N]:
安装成功后,查看GCC版本

gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)

cuda 驱动资料,对gcc有版本要求,官方源安装的版本太低4.8.5,需要at least GCC 5,看提示需要安装Red Hat Developer Toolset

(2) Note that starting with CUDA 11.0, the minimum recommended GCC compiler is at least GCC 5 due to C++11 requirements in CUDA libraries e.g. cuFFT and CUB. On distributions such as RHEL 7 or CentOS 7 that may use an older GCC toolchain by default, it is recommended to use a newer GCC toolchain with CUDA 11.0. Newer GCC toolchains are available with the [Red Hat Developer Toolset](https://developers.redhat.com/products/developertoolset/overview).

https://developers.redhat.com/products/developertoolset/overview

https://access.redhat.com/documentation/en-us/red_hat_developer_toolset/6/html/user_guide/sect-red_hat_developer_toolset-install


安装centos 集成developertoolset

yum install centos-release-scl

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, langpacks, nvidia
Loading mirror speeds from cached hostfile
 * epel: mirrors.bestthaihost.com
Resolving Dependencies
--> Running transaction check
---> Package centos-release-scl.noarch 0:2-3.el7.centos will be installed
--> Processing Dependency: centos-release-scl-rh for package: centos-release-scl-2-3.el7.centos.noarch
--> Running transaction check
---> Package centos-release-scl-rh.noarch 0:2-3.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================================================================
 Package                                                  Arch                                      Version                                           Repository                                 Size
======================================================================================================================================================================================================
Installing:
 centos-release-scl                                       noarch                                    2-3.el7.centos                                    extras                                     12 k
Installing for dependencies:
 centos-release-scl-rh                                    noarch                                    2-3.el7.centos                                    extras                                     12 k

Transaction Summary
======================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 24 k
Installed size: 39 k
Is this ok [y/d/N]: y
Downloading packages:
(1/2): centos-release-scl-2-3.el7.centos.noarch.rpm                                                                                                                            |  12 kB  00:00:00
(2/2): centos-release-scl-rh-2-3.el7.centos.noarch.rpm                                                                                                                         |  12 kB  00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                 113 kB/s |  24 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : centos-release-scl-rh-2-3.el7.centos.noarch                                                                                                                                        1/2
  Installing : centos-release-scl-2-3.el7.centos.noarch                                                                                                                                           2/2
  Verifying  : centos-release-scl-2-3.el7.centos.noarch                                                                                                                                           1/2
  Verifying  : centos-release-scl-rh-2-3.el7.centos.noarch                                                                                                                                        2/2

Installed:
  centos-release-scl.noarch 0:2-3.el7.centos

Dependency Installed:
  centos-release-scl-rh.noarch 0:2-3.el7.centos

Complete!
安装centos的devtoolset 集成gcc

yum install devtoolset-9

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, langpacks, nvidia
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.cqu.edu.cn
 * centos-sclo-sclo: mirrors.163.com
 * epel: mirrors.bestthaihost.com
centos-sclo-rh                                                                                                                                                                 | 3.0 kB  00:00:00
centos-sclo-sclo                                                                                                                                                               | 3.0 kB  00:00:00
(1/2): centos-sclo-sclo/x86_64/primary_db                                                                                                                                      | 291 kB  00:00:00
(2/2): centos-sclo-rh/x86_64/primary_db                                                                                                                                        | 2.9 MB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package devtoolset-9.x86_64 0:9.1-0.el7 will be installed
--> Processing Dependency: devtoolset-9-perftools for package: devtoolset-9-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-runtime for package: devtoolset-9-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-toolchain for package: devtoolset-9-9.1-0.el7.x86_64
--> Running transaction check
---> Package devtoolset-9-perftools.x86_64 0:9.1-0.el7 will be installed
--> Processing Dependency: devtoolset-9-oprofile for package: devtoolset-9-perftools-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-systemtap for package: devtoolset-9-perftools-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-valgrind for package: devtoolset-9-perftools-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-dyninst for package: devtoolset-9-perftools-9.1-0.el7.x86_64
---> Package devtoolset-9-runtime.x86_64 0:9.1-0.el7 will be installed
---> Package devtoolset-9-toolchain.x86_64 0:9.1-0.el7 will be installed
--> Processing Dependency: devtoolset-9-gcc for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-gcc-c++ for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-gcc-gfortran for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-binutils for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-gdb for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-strace for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-dwz for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-elfutils for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-memstomp for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-ltrace for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Processing Dependency: devtoolset-9-make for package: devtoolset-9-toolchain-9.1-0.el7.x86_64
--> Running transaction check
---> Package devtoolset-9-binutils.x86_64 0:2.32-16.el7 will be installed
---> Package devtoolset-9-dwz.x86_64 0:0.12-1.1.el7 will be installed
---> Package devtoolset-9-dyninst.x86_64 0:10.1.0-4.el7 will be installed
--> Processing Dependency: libdw.so.dts.1(ELFUTILS_0.122)(64bit) for package: devtoolset-9-dyninst-10.1.0-4.el7.x86_64
--> Processing Dependency: libdw.so.dts.1(ELFUTILS_0.142)(64bit) for package: devtoolset-9-dyninst-10.1.0-4.el7.x86_64
--> Processing Dependency: libdw.so.dts.1(ELFUTILS_0.148)(64bit) for package: devtoolset-9-dyninst-10.1.0-4.el7.x86_64
--> Processing Dependency: libdw.so.dts.1(ELFUTILS_0.157)(64bit) for package: devtoolset-9-dyninst-10.1.0-4.el7.x86_64
--> Processing Dependency: libdw.so.dts.1(ELFUTILS_0.173)(64bit) for package: devtoolset-9-dyninst-10.1.0-4.el7.x86_64
--> Processing Dependency: libelf.so.dts.1(ELFUTILS_1.0)(64bit) for package: devtoolset-9-dyninst-10.1.0-4.el7.x86_64
--> Processing Dependency: libdw.so.dts.1()(64bit) for package: devtoolset-9-dyninst-10.1.0-4.el7.x86_64
--> Processing Dependency: libelf.so.dts.1()(64bit) for package: devtoolset-9-dyninst-10.1.0-4.el7.x86_64
---> Package devtoolset-9-elfutils.x86_64 0:0.176-6.el7 will be installed
---> Package devtoolset-9-gcc.x86_64 0:9.3.1-2.el7 will be installed
---> Package devtoolset-9-gcc-c++.x86_64 0:9.3.1-2.el7 will be installed
--> Processing Dependency: devtoolset-9-libstdc++-devel = 9.3.1-2.el7 for package: devtoolset-9-gcc-c++-9.3.1-2.el7.x86_64
---> Package devtoolset-9-gcc-gfortran.x86_64 0:9.3.1-2.el7 will be installed
--> Processing Dependency: devtoolset-9-libquadmath-devel = 9.3.1-2.el7 for package: devtoolset-9-gcc-gfortran-9.3.1-2.el7.x86_64
--> Processing Dependency: libgfortran5 >= 8.1.1 for package: devtoolset-9-gcc-gfortran-9.3.1-2.el7.x86_64
---> Package devtoolset-9-gdb.x86_64 0:8.3-3.el7 will be installed
--> Processing Dependency: libboost_regex.so.1.53.0()(64bit) for package: devtoolset-9-gdb-8.3-3.el7.x86_64
--> Processing Dependency: libsource-highlight.so.4()(64bit) for package: devtoolset-9-gdb-8.3-3.el7.x86_64
---> Package devtoolset-9-ltrace.x86_64 0:0.7.91-2.el7 will be installed
---> Package devtoolset-9-make.x86_64 1:4.2.1-2.el7 will be installed
---> Package devtoolset-9-memstomp.x86_64 0:0.1.5-5.el7 will be installed
---> Package devtoolset-9-oprofile.x86_64 0:1.3.0-4.el7 will be installed
---> Package devtoolset-9-strace.x86_64 0:5.1-7.el7 will be installed
---> Package devtoolset-9-systemtap.x86_64 0:4.1-9.el7 will be installed
--> Processing Dependency: devtoolset-9-systemtap-client = 4.1-9.el7 for package: devtoolset-9-systemtap-4.1-9.el7.x86_64
--> Processing Dependency: devtoolset-9-systemtap-devel = 4.1-9.el7 for package: devtoolset-9-systemtap-4.1-9.el7.x86_64
---> Package devtoolset-9-valgrind.x86_64 1:3.15.0-9.el7 will be installed
--> Running transaction check
---> Package boost-regex.x86_64 0:1.53.0-28.el7 will be installed
---> Package devtoolset-9-elfutils-libelf.x86_64 0:0.176-6.el7 will be installed
---> Package devtoolset-9-elfutils-libs.x86_64 0:0.176-6.el7 will be installed
---> Package devtoolset-9-libquadmath-devel.x86_64 0:9.3.1-2.el7 will be installed
--> Processing Dependency: libquadmath(x86-64) for package: devtoolset-9-libquadmath-devel-9.3.1-2.el7.x86_64
---> Package devtoolset-9-libstdc++-devel.x86_64 0:9.3.1-2.el7 will be installed
---> Package devtoolset-9-systemtap-client.x86_64 0:4.1-9.el7 will be installed
--> Processing Dependency: devtoolset-9-systemtap-runtime = 4.1-9.el7 for package: devtoolset-9-systemtap-client-4.1-9.el7.x86_64
---> Package devtoolset-9-systemtap-devel.x86_64 0:4.1-9.el7 will be installed
---> Package libgfortran5.x86_64 0:8.3.1-2.1.1.el7 will be installed
---> Package source-highlight.x86_64 0:3.1.6-6.el7 will be installed
--> Processing Dependency: ctags for package: source-highlight-3.1.6-6.el7.x86_64
--> Running transaction check
---> Package ctags.x86_64 0:5.8-13.el7 will be installed
---> Package devtoolset-9-systemtap-runtime.x86_64 0:4.1-9.el7 will be installed
---> Package libquadmath.x86_64 0:4.8.5-39.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================================================================
 Package                                                      Arch                                 Version                                         Repository                                    Size
======================================================================================================================================================================================================
Installing:
 devtoolset-9                                                 x86_64                               9.1-0.el7                                       centos-sclo-rh                               5.4 k
Installing for dependencies:
 boost-regex                                                  x86_64                               1.53.0-28.el7                                   base                                         296 k
 ctags                                                        x86_64                               5.8-13.el7                                      base                                         155 k
 devtoolset-9-binutils                                        x86_64                               2.32-16.el7                                     centos-sclo-rh                               5.9 M
 devtoolset-9-dwz                                             x86_64                               0.12-1.1.el7                                    centos-sclo-rh                                98 k
 devtoolset-9-dyninst                                         x86_64                               10.1.0-4.el7                                    centos-sclo-rh                               3.8 M
 devtoolset-9-elfutils                                        x86_64                               0.176-6.el7                                     centos-sclo-rh                               431 k
 devtoolset-9-elfutils-libelf                                 x86_64                               0.176-6.el7                                     centos-sclo-rh                               203 k
 devtoolset-9-elfutils-libs                                   x86_64                               0.176-6.el7                                     centos-sclo-rh                               311 k
 devtoolset-9-gcc                                             x86_64                               9.3.1-2.el7                                     centos-sclo-rh                                32 M
 devtoolset-9-gcc-c++                                         x86_64                               9.3.1-2.el7                                     centos-sclo-rh                                12 M
 devtoolset-9-gcc-gfortran                                    x86_64                               9.3.1-2.el7                                     centos-sclo-rh                                13 M
 devtoolset-9-gdb                                             x86_64                               8.3-3.el7                                       centos-sclo-rh                               3.6 M
 devtoolset-9-libquadmath-devel                               x86_64                               9.3.1-2.el7                                     centos-sclo-rh                               171 k
 devtoolset-9-libstdc++-devel                                 x86_64                               9.3.1-2.el7                                     centos-sclo-rh                               3.1 M
 devtoolset-9-ltrace                                          x86_64                               0.7.91-2.el7                                    centos-sclo-rh                               148 k
 devtoolset-9-make                                            x86_64                               1:4.2.1-2.el7                                   centos-sclo-rh                               485 k
 devtoolset-9-memstomp                                        x86_64                               0.1.5-5.el7                                     centos-sclo-rh                               442 k
 devtoolset-9-oprofile                                        x86_64                               1.3.0-4.el7                                     centos-sclo-rh                               1.8 M
 devtoolset-9-perftools                                       x86_64                               9.1-0.el7                                       centos-sclo-rh                               2.8 k
 devtoolset-9-runtime                                         x86_64                               9.1-0.el7                                       centos-sclo-rh                                20 k
 devtoolset-9-strace                                          x86_64                               5.1-7.el7                                       centos-sclo-rh                               1.1 M
 devtoolset-9-systemtap                                       x86_64                               4.1-9.el7                                       centos-sclo-rh                                13 k
 devtoolset-9-systemtap-client                                x86_64                               4.1-9.el7                                       centos-sclo-rh                               2.9 M
 devtoolset-9-systemtap-devel                                 x86_64                               4.1-9.el7                                       centos-sclo-rh                               2.3 M
 devtoolset-9-systemtap-runtime                               x86_64                               4.1-9.el7                                       centos-sclo-rh                               433 k
 devtoolset-9-toolchain                                       x86_64                               9.1-0.el7                                       centos-sclo-rh                               3.0 k
 devtoolset-9-valgrind                                        x86_64                               1:3.15.0-9.el7                                  centos-sclo-rh                                12 M
 libgfortran5                                                 x86_64                               8.3.1-2.1.1.el7                                 base                                         796 k
 libquadmath                                                  x86_64                               4.8.5-39.el7                                    base                                         190 k
 source-highlight                                             x86_64                               3.1.6-6.el7                                     base                                         611 k

Transaction Summary
======================================================================================================================================================================================================
Install  1 Package (+30 Dependent packages)

Total download size: 98 M
Installed size: 292 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/centos-sclo-rh/packages/devtoolset-9-9.1-0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f2ee9d55: NOKEY
Public key for devtoolset-9-9.1-0.el7.x86_64.rpm is not installed
(1/31): devtoolset-9-9.1-0.el7.x86_64.rpm                                                                                                                                      | 5.4 kB  00:00:00
(2/31): ctags-5.8-13.el7.x86_64.rpm                                                                                                                                            | 155 kB  00:00:00
(3/31): boost-regex-1.53.0-28.el7.x86_64.rpm                                                                                                                                   | 296 kB  00:00:00
(4/31): devtoolset-9-dwz-0.12-1.1.el7.x86_64.rpm                                                                                                                               |  98 kB  00:00:00
(5/31): devtoolset-9-binutils-2.32-16.el7.x86_64.rpm                                                                                                                           | 5.9 MB  00:00:00
(6/31): devtoolset-9-elfutils-0.176-6.el7.x86_64.rpm                                                                                                                           | 431 kB  00:00:00
(7/31): devtoolset-9-dyninst-10.1.0-4.el7.x86_64.rpm                                                                                                                           | 3.8 MB  00:00:00
(8/31): devtoolset-9-elfutils-libelf-0.176-6.el7.x86_64.rpm                                                                                                                    | 203 kB  00:00:00
(9/31): devtoolset-9-elfutils-libs-0.176-6.el7.x86_64.rpm                                                                                                                      | 311 kB  00:00:00
(10/31): devtoolset-9-gcc-c++-9.3.1-2.el7.x86_64.rpm                                                                                                                           |  12 MB  00:00:00
(11/31): devtoolset-9-gcc-gfortran-9.3.1-2.el7.x86_64.rpm                                                                                                                      |  13 MB  00:00:00
(12/31): devtoolset-9-gcc-9.3.1-2.el7.x86_64.rpm                                                                                                                               |  32 MB  00:00:00
(13/31): devtoolset-9-gdb-8.3-3.el7.x86_64.rpm                                                                                                                                 | 3.6 MB  00:00:00
(14/31): devtoolset-9-libquadmath-devel-9.3.1-2.el7.x86_64.rpm                                                                                                                 | 171 kB  00:00:00
(15/31): devtoolset-9-ltrace-0.7.91-2.el7.x86_64.rpm                                                                                                                           | 148 kB  00:00:00
(16/31): devtoolset-9-libstdc++-devel-9.3.1-2.el7.x86_64.rpm                                                                                                                   | 3.1 MB  00:00:00
(17/31): devtoolset-9-make-4.2.1-2.el7.x86_64.rpm                                                                                                                              | 485 kB  00:00:00
(18/31): devtoolset-9-memstomp-0.1.5-5.el7.x86_64.rpm                                                                                                                          | 442 kB  00:00:00
(19/31): devtoolset-9-perftools-9.1-0.el7.x86_64.rpm                                                                                                                           | 2.8 kB  00:00:00
(20/31): devtoolset-9-oprofile-1.3.0-4.el7.x86_64.rpm                                                                                                                          | 1.8 MB  00:00:00
(21/31): devtoolset-9-runtime-9.1-0.el7.x86_64.rpm                                                                                                                             |  20 kB  00:00:00
(22/31): devtoolset-9-strace-5.1-7.el7.x86_64.rpm                                                                                                                              | 1.1 MB  00:00:00
(23/31): devtoolset-9-systemtap-4.1-9.el7.x86_64.rpm                                                                                                                           |  13 kB  00:00:00
(24/31): devtoolset-9-systemtap-client-4.1-9.el7.x86_64.rpm                                                                                                                    | 2.9 MB  00:00:00
(25/31): devtoolset-9-systemtap-devel-4.1-9.el7.x86_64.rpm                                                                                                                     | 2.3 MB  00:00:00
(26/31): devtoolset-9-systemtap-runtime-4.1-9.el7.x86_64.rpm                                                                                                                   | 433 kB  00:00:00
(27/31): devtoolset-9-toolchain-9.1-0.el7.x86_64.rpm                                                                                                                           | 3.0 kB  00:00:00
(28/31): libquadmath-4.8.5-39.el7.x86_64.rpm                                                                                                                                   | 190 kB  00:00:00
(29/31): devtoolset-9-valgrind-3.15.0-9.el7.x86_64.rpm                                                                                                                         |  12 MB  00:00:00
(30/31): source-highlight-3.1.6-6.el7.x86_64.rpm                                                                                                                               | 611 kB  00:00:00
(31/31): libgfortran5-8.3.1-2.1.1.el7.x86_64.rpm                                                                                                                               | 796 kB  00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                  40 MB/s |  98 MB  00:00:02
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Importing GPG key 0xF2EE9D55:
 Userid     : "CentOS SoftwareCollections SIG (https://wiki.centos.org/SpecialInterestGroup/SCLo) <security@centos.org>"
 Fingerprint: c4db d535 b1fb ba14 f8ba 64a8 4eb8 4e71 f2ee 9d55
 Package    : centos-release-scl-rh-2-3.el7.centos.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
查看gcc版本 还不对,使用的还是gcc 4.8.5
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 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.
切换gcc,后查看gcc版本,成功切换为GCC 9.3.1

scl enable devtoolset-9 bash

gcc --version

gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 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.
gcc 搞定了,然后安装编译需要的内核包,但是官方源找不到相应的包

yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r)

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, langpacks, nvidia
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.neusoft.edu.cn
 * centos-sclo-sclo: mirrors.163.com
 * epel: mirrors.bestthaihost.com
No package kernel-devel-3.10.0-1062.12.1.el7.x86_64 available.
No package kernel-headers-3.10.0-1062.12.1.el7.x86_64 available.
Error: Nothing to do
看看问题在哪

yum install kernel-devel

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, langpacks, nvidia
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: ftp.sjtu.edu.cn
 * centos-sclo-sclo: ftp.sjtu.edu.cn
 * epel: mirrors.bestthaihost.com
Package kernel-devel-3.10.0-1127.13.1.el7.x86_64 already installed and latest version
Nothing to do

uname -r
3.10.0-1062.12.1.el7.x86_64
那就只好找rpm文件了,https://pkgs.org/download/kernel-headers

找到了相应的rpm包

下载 kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm

Saving to: 'kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm'

100%[============================================================================================================================================================>] 9,170,080   4.65MB/s   in 1.9s

2020-07-29 17:32:11 (4.65 MB/s) - 'kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm' saved [9170080/9170080]

[root@b2b-qa-cne2-goldradar-etlgpu-0 cdp]#
[root@b2b-qa-cne2-goldradar-etlgpu-0 cdp]# rpm -Uvh elrepo-release*rpm
error: File not found by glob: elrepo-release*rpm
[root@b2b-qa-cne2-goldradar-etlgpu-0 cdp]# rpm -Uvh kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm
warning: kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 53e4e7a9: NOKEY
warning: package kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64 was already added, skipping kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64
Preparing...                          ################################# [100%]
	package kernel-headers-3.10.0-1127.13.1.el7.x86_64 (which is newer than kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64) is already installed

https://pkgs.org/download/kernel-headers

内核安装相关资料
https://centos.pkgs.org/7/lux/kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm.html

1. Download latest lux-release rpm fromhttp://repo.iotti.biz/CentOS/7/noarch/

2. Install lux-release rpm:# rpm -Uvh elrepo-release*rpm

3. Install kernel-headers rpm package:# yum install kernel-headers

移除旧的,安装下载好的正确rpm包

rpm -Uvh elrepo-release*rpm

error: File not found by glob: elrepo-release*rpm

rpm -Uvh kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm

warning: kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 53e4e7a9: NOKEY
warning: package kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64 was already added, skipping kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64
Preparing...                          ################################# [100%]
	package kernel-headers-3.10.0-1127.13.1.el7.x86_64 (which is newer than kernel-headers-3.10.0-1062.12.1.el7.centos.plus.x86_64) is already installed
gcc和内核相关万事俱备准备,安装驱动,又报错

安装前

lspci -vnn | grep VGA

0000:00:08.0 VGA compatible controller [0300]: Microsoft Corporation Hyper-V virtual VGA [1414:5353] (prog-if 00 [VGA controller])

安装驱动出错

sh NVIDIA-Linux-x86_64-450.51.06.run

  ERROR: Unable to find the kernel source tree for the currently running kernel.  Please make sure you have installed the kernel source files for your kernel and that they are properly configured;
         on Red Hat Linux systems, for example, be sure you have the 'kernel-source' or 'kernel-devel' RPM installed.  If you know the correct kernel source files are installed, you may specify
         the kernel source path with the '--kernel-source-path' command line option.

因为没指定--kernel-source-path 目录

找到目录地址为 /usr/src/kernels/3.10.0-1062.12.1.el7.centos.plus.x86_64/,添加参数,再次安装

sh NVIDIA-Linux-x86_64-450.51.06.run --kernel-source-path /usr/src/kernels/3.10.0-1062.12.1.el7.centos.plus.x86_64/

NVIDIA Accelerated Graphics Driver for Linux-x86_64 (450.51.06)

NVIDIA Accelerated Graphics Driver-5

WARNING Unable to determine the path to install the libglvnd EGL vendor library config files. Check that you have pkg-config and-4

NVIDIA Accelerated Graphics Driver for Linux-x86_64 (450.51.06)-3

NVIDIA Accelerated Graphics Driver for Linux-x86_64 (450.51.06)-2

NVIDIA Accelerated Graphics Driver for Linux-x86_64 (450.51.06)-1

因为编译内核的gcc和安装驱动的gcc版本不一致,因此会有报警,无视即可

大功告成

posted @ 2021-03-04 23:18  cclient  阅读(690)  评论(0编辑  收藏  举报