银河麒麟 关闭 X 服务器的情况下成功安装 NVIDIA 驱动

bash 复制代码
nvidia-installer log file '/var/log/nvidia-installer.log'
creation time: Thu Sep 19 21:23:01 2024
installer version: 560.35.03

PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

nvidia-installer command line:
    ./nvidia-installer
    --ui=none
    --no-questions
    --accept-license
    --disable-nouveau
    --no-cc-version-check
    --install-libglvnd

Using built-in stream user interface
-> Detected 20 CPUs online; setting concurrency level to 20.
-> Scanning the initramfs with lsinitramfs...
-> Executing: /usr/bin/lsinitramfs   -l /boot/initrd.img-5.10.0-9-generic
-> The file '/tmp/.X0-lock' exists and appears to contain the process ID '33536' of a running X server.
-> You appear to be running an X server.  Installing the NVIDIA driver while X is running is not recommended, as doing so may prevent the installer from detecting some potential installation problems, and it may not be possible to start new graphics applications after a new driver is installed.  If you choose to continue installation, it is highly recommended that you reboot your computer after installation to use the newly installed driver. (Answer: Abort installation)
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. 

日志表明,NVIDIA 驱动安装失败的原因是 X 服务器正在运行,而 NVIDIA 驱动安装程序不推荐在 X 服务器运行时进行安装。这可能会导致潜在的安装问题,并且在安装完成后,可能无法正常启动新的图形应用程序。

问题分析:

正在运行的 X 服务器:X 服务器是 Linux 系统中的图形界面处理组件,当你在使用桌面时,它通常在后台运行。安装 NVIDIA 驱动时,必须关闭 X 服务器,否则安装可能失败。

推荐的操作:安装程序建议你关闭 X 服务器再继续安装,并在安装完成后重启系统来使新的驱动生效。

解决方案:

1. 关闭 X 服务器再安装:

切换到纯文本模式,按 Ctrl + Alt + F2(或 F3、F4 等)进入命令行界面。

登录你的系统,然后关闭 X 服务器:

bash 复制代码
sudo systemctl stop lightdm  # 对于 Ubuntu 或 Kylin 等桌面环境

或者:

bash 复制代码
sudo systemctl stop gdm  # 如果你使用的是 GNOME

在关闭 X 服务器之后,重新运行 NVIDIA 安装程序:

bash 复制代码
sudo ./cuda**--no-cc-version-check --install-libglvnd

安装完成后,重新启动系统:

bash 复制代码
sudo reboot

2. 切换到恢复模式安装

如果你不想在 X 服务器运行时手动停止它,你可以选择在系统启动时进入恢复模式(Recovery Mode),以命令行方式安装驱动。在 GRUB 菜单上,选择 "Advanced options" 然后选择 "Recovery mode",此时系统将以命令行模式启动,不会启动 X 服务器。然后运行安装程序。

3. 禁用 Nouveau 驱动: 确保 Nouveau(开源的 NVIDIA 驱动)已被禁用:

编辑 /etc/modprobe.d/blacklist.conf 文件:

bash 复制代码
sudo vim /etc/modprobe.d/blacklist.conf

添加以下内容:

bash 复制代码
blacklist nouveau
options nouveau modeset=0

生成新的 initramfs:

bash 复制代码
sudo update-initramfs -u

检查依赖项: 安装必要的依赖项,确保驱动安装过程中不会出现缺少软件包的问题:

bash 复制代码
sudo apt-get update
sudo apt-get install build-essential linux-headers-$(uname -r)

银河麒麟 后面还是遇到了 权限问题

相关推荐
消失的旧时光-194311 分钟前
Linux 入门核心命令清单(工程版)
linux·运维·服务器
艾莉丝努力练剑18 分钟前
【Linux:文件】Ext系列文件系统(初阶)
大数据·linux·运维·服务器·c++·人工智能·算法
小天源22 分钟前
Cacti在Debian/Ubuntu中安装及其使用
运维·ubuntu·debian·cacti
Trouvaille ~44 分钟前
【Linux】TCP Socket编程实战(一):API详解与单连接Echo Server
linux·运维·服务器·网络·c++·tcp/ip·socket
芷栀夏1 小时前
深度解析 CANN 异构计算架构:基于 ACL API 的算子调用实战
运维·人工智能·开源·cann
全栈工程师修炼指南1 小时前
Nginx | stream 四层反向代理:SSL、PREREAD 阶段模块指令浅析与实践
运维·网络·网络协议·nginx·ssl
威迪斯特2 小时前
CentOS图形化操作界面:理论解析与实践指南
linux·运维·centos·组件·图形化·桌面·xserver
一方热衷.2 小时前
在线安装对应版本NVIDIA驱动
linux·运维·服务器
独自归家的兔2 小时前
ubuntu系统安装dbswitch教程 - 备份本地数据到远程服务器
linux·运维·ubuntu
m0_694845572 小时前
tinylisp 是什么?超轻量 Lisp 解释器编译与运行教程
服务器·开发语言·云计算·github·lisp