解决ubuntu 22.04新内核6.5.0-15无法编译NVIDIA显卡驱动

04-01 阅读 0评论

这里的新内核应该包括6.5.*系列的

解决ubuntu 22.04新内核6.5.0-15无法编译NVIDIA显卡驱动,解决ubuntu 22.04新内核6.5.0-15无法编译NVIDIA显卡驱动,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,使用,我们,安装,第1张
(图片来源网络,侵删)

文章目录

    • 遇到的问题:

      遇到的问题:

      今天我在安装NVIDIA显卡驱动发现了一个问题,主要日志如下所示:

      make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz1310041/NVIDIA-Linux-x86_64-550.54.14/kernel/nvidia/nvlink_linux.o] Error 1
      make[3]: Target '/tmp/selfgz1310041/NVIDIA-Linux-x86_64-550.54.14/kernel/' not remade because of errors.
      make[2]: *** [/usr/src/linux-headers-6.5.0-15-generic/Makefile:2037: /tmp/selfgz1310041/NVIDIA-Linux-x86_64-550.54.14/kernel] Error 2
      make[2]: Target 'modules' not remade because of errors.
      make[1]: *** [Makefile:234: __sub-make] Error 2
      make[1]: Target 'modules' not remade because of errors.
      make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-15-generic'
      make: *** [Makefile:85: modules] Error 2
      ERROR: The nvidia kernel module was not created.
      ERROR: Installation has failed.  Please see the file '/var/log/nvidia-installer.log' for details.  You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.
      

      从这个日志可以发现,他与内核冲突了。于是借助魔法搜到了ubuntuforums.org的多种方法,一个是换内核版本,有人说切换到6.2系列就好了,但我实在不行破坏内核,万一改了内核其它功能炸了。在我的不断努力之下,终于找到一个偷渡方法,但直接用这个方法我还是无法安装成功,结果我死马当活马医重新覆盖的时候,我在新内核下安装成功了!

      出现问题原因在于当前内核下的GCC版本在编译现在的NVIDIA显卡内核(我下载的是550.54.14)不兼容。

      使用gcc --version | grep -e 'gcc'观察到我的GCC版本是11,而推荐的版本是12。然后没办法,我们就自己安装个gcc-12吧。

      sudo apt update
      sudo apt install gcc-12 g++-12
      

      然后把现有的2个版本添加到 update-alternatives 组

      sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
      sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12
      

      暂时默认选择gcc-12:

      解决ubuntu 22.04新内核6.5.0-15无法编译NVIDIA显卡驱动,解决ubuntu 22.04新内核6.5.0-15无法编译NVIDIA显卡驱动,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,使用,我们,安装,第2张
      (图片来源网络,侵删)
      $ sudo update-alternatives --config gcc
      There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
        Selection    Path             Priority   Status
      ------------------------------------------------------------
      * 0            /usr/bin/gcc-12   12        auto mode
        1            /usr/bin/gcc-11   11        manual mode
        2            /usr/bin/gcc-12   12        manual mode
      Press  to keep the current choice[*], or type selection number: 2
      

      我感觉这里的意思是,我们还是切换成手动模式保险,保不齐编译时候突然变成gcc-11了。

      接下来安装驱动程序:sudo apt install --yes nvidia-driver-535 nvidia-dkms-535 nvidia-cuda-toolkit

      到这里教程就说成功了,就当我激动得输入nvidia-smi时候,又报错了:NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

      好好好,那我就再执行sudo bash NVIDIA-Linux-x86_64-550.54.14.run安装一下,其实这里我感觉是gcc-12那选定版本之后直接安装run文件就好了。但我没有试,因为我已经安装成功了!

      最后附上成功的结果,证明我教程的可行性:

      解决ubuntu 22.04新内核6.5.0-15无法编译NVIDIA显卡驱动

      解决ubuntu 22.04新内核6.5.0-15无法编译NVIDIA显卡驱动

      转载于染念的个人博客

      参考:

      • https://ubuntuforums.org/showthread.php?t=2494273&page=3&p=14176039#post14176039

免责声明
本网站所收集的部分公开资料来源于AI生成和互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
评论列表 (暂无评论,人围观)

还没有评论,来说两句吧...

目录[+]