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

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

相关推荐
Source.Liu7 分钟前
【Ubuntu】文件与目录管理命令
linux·运维·ubuntu
Elastic 中国社区官方博客9 分钟前
Agent Builder,超越聊天框:推出增强型基础设施
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
周公挚友43 分钟前
centos 7.9 防火墙
linux·运维·centos
宇钶宇夕44 分钟前
CoDeSys入门实战一起学习(十六):采样跟踪功能详解
运维·自动化·软件工程
梁正雄1 小时前
linux服务-麒麟10安装sqlserver
linux·运维·sqlserver
飞Link1 小时前
cmd、powershell、linux下命令对比
linux·运维·服务器
zabbix研究生1 小时前
2026全栈运维监控平台选型指南:主流产品深度对比
运维
爱上猫de鱼1 小时前
linux环境docker部署前后端应用
linux·运维·docker
EverydayJoy^v^1 小时前
RH134简单知识点——第5章——调优系统性能
linux·运维·服务器
RisunJan1 小时前
Linux命令-lastlog(显示系统中所有用户的最近一次登录信息)
linux·运维·服务器