银河麒麟 关闭 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)

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

相关推荐
likfishdn17 分钟前
Linux的文件与目录管理
linux·运维·服务器
渲染101专业云渲染19 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
chian-ocean37 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=39 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
橘子味的茶二1 小时前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
北京耐用通信2 小时前
航空装配自动化神器Ethercat转profient网关搭配机器人精准控制
运维·机器人·自动化
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net