Ubuntu20.04 您所在的位置:网站首页 怎么删除nvidia安装包 Ubuntu20.04

Ubuntu20.04

2023-07-03 23:04| 来源: 网络整理| 查看: 265

1. 屏蔽原有开源驱动 sudo gedit /etc/modprobe.d/blacklist.conf # 在文件末尾输入 blacklist nouveau options nouveau modeset=0 # 更新 sudo update-initramfs -u # 重启 reboot # 重启后验证是否完成屏蔽 lsmod | grep nouveau # 无输出则屏蔽成功 2. 查看显卡型号 # 查看nvidia显卡型号 lspci | grep -i nvidia # 输出 01:00.0 3D controller: NVIDIA Corporation Device 25a0 (rev a1) # 查看集成显卡型号 lspci | grep -i vga

The PCI ID Repository可以按照十六进制数字代码找到相应的显卡型号。

3. NVIDIA官网下载驱动

按照显卡型号下载驱动 (ctrl+鼠标点击-》跳转)下载官网建议的.run文件,下载完成后移动到主目录。

4. 安装显卡驱动 # 添加权限 sudo chmod a+x NVIDIA-Linux-x86_64-*.run # 安装 sudo ./NVIDIA-Linux-x86_64-*.run -no-x-check -no-nouveau-check // -no-opengl-files 只安装驱动文件,不安装OpenGL文件(据说台式机需要,否则会循环登录) // -no-x-check 安装驱动时不检查X服务(for:you appear to be running an x server pleaseexit x before installing) // -no-nouveau-check 安装驱动时不检查nouveau // 安装过程中会询问是否安装32位的,选择 NO # 安装完成后挂载nvidia modprobe nvidia # 验证是否安装成功 nvidia-smi // 会显示显卡温度,风扇转数等信息 # 安装选择显卡的工具 sudo apt install nvidia-prime # 选择使用nvidia sudo prime-select nvidia // nvidia 使用nivdia显卡 // intel 使用intel集成显卡 // on-demand 使用混合显卡 // query 查看当前使用的显卡 5. 卸载NVIDIA显卡驱动 # 按照上述教程安装的 sudo ./NVIDIA-Linux-x86_64-*.run --uninstall # 使用sudo安装或者ubuntu软件更新器里面安装的 sudo apt remove --purge nvidia* sudo apt autoremove 6. 解决黑屏问题

问题描述:在进行prime-select nvidia后,重启电脑,左上角光标闪烁,无法进入登录页面。如果你恰巧执行了 nvidia-xconfig 命令,生成 /etc/X11/xorg.conf 之后,系统也还是进不去,**但是不会再一直循环登陆,而是登陆之后直接就卡住了。**问题出现在 X11 的配置文件上。相关参考链接如下:

稍微深入分析Ubuntu环境下安装NVIDIA驱动导致黑屏的原因

Why black screen after run sudo nvidia-xconfig

ubuntu安装nvidia驱动后循环登陆/登陆界面卡住

解决思路:

vidia-xconfig 是只为英伟达的显卡设置 xorg 配置文件,在核显+独显的电脑上,这个配置文件是无效的。于是就会出现登陆后直接卡住的问题在没有 xorg.conf 的情况下,X server 会检测系统状态并且自动生成配置。但是自动生成的配置把独显的驱动检测成了 nouveau(nvidia 驱动安装中禁用掉的系统自带的驱动)。于是在这种情况下,如果使用了 prime-select 把默认显卡设置成了独显,系统会因为找不到驱动而一直启动失败,此时会造成循环登陆

解决步骤:

# 终端执行 sudo nvidia-xconfig # 此时会在/etc/X11中生成xorg.conf文件,打开进行编辑 sudo gedit /etc/X11/xorg.conf

将其替换为以下内容,手动在 nvidia-xconfig 生成的文件中添加对 intel 显卡的支持

# nvidia-xconfig: X configuration file generated by nvidia-xconfig # nvidia-xconfig: version 535.54.03 Section "ServerLayout" Identifier "Layout0" Screen 0 "Screen0" InputDevice "Keyboard0" "CoreKeyboard" InputDevice "Mouse0" "CorePointer" EndSection Section "Files" EndSection Section "InputDevice" # generated from default Identifier "Mouse0" Driver "mouse" Option "Protocol" "auto" Option "Device" "/dev/psaux" Option "Emulate3Buttons" "no" Option "ZAxisMapping" "4 5" EndSection Section "InputDevice" # generated from default Identifier "Keyboard0" Driver "kbd" EndSection Section "Monitor" Identifier "Monitor0" VendorName "Unknown" ModelName "Unknown" Option "DPMS" EndSection Section "Device" Identifier "Device0" Driver "nvidia" VendorName "NVIDIA Corporation" # 添加显卡型号 BoardName "NVIDIA GeForce RTX3050TI" BusID "PCI:1:0:0" EndSection # intel显卡 Section "Device" Identifier "intel" Driver "modesetting" BusID "PCI:0:2:0" EndSection Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Depth 24 EndSubSection EndSection

其中BusID可以用以下命令查看

xxxxxx:~$ lspci -k | grep -EA3 'VGA|3D|Display' 00:02.0 VGA compatible controller: Intel Corporation Device 46a6 (rev 0c) DeviceName: Onboard IGD Subsystem: Hewlett-Packard Company Device 89c0 Kernel driver in use: i915 -- 01:00.0 3D controller: NVIDIA Corporation Device 25a0 (rev a1) Subsystem: Hewlett-Packard Company Device 89c1 Kernel driver in use: nvidia Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia 7. 其它 # 安装图形界面管理器 sudo apt install lightdm # 切换 sudo dpkg-reconfigure lightdm // 登录在左边 sudo dpkg-reconfigure gdm3 // 登录在中间 8. 补充

更新:20230630又遇到无法进入图形界面的问题,发现是由于linux内核自动更新导致,关闭内核自动更新步骤如下

# 保持当前内核 sudo apt-mark hold linux-image-generic linux-headers-generic # 解除保持 sudo apt-mark unhold linux-image-generic linux-headers-generic # 修改配置 sudo vim /etc/apt/apt.conf.d/10periodic # 原来是这样的 APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "0"; APT::Periodic::AutocleanInterval "0"; APT::Periodic::Unattended-Upgrade "1"; # 改成这样的 APT::Periodic::Update-Package-Lists "0"; APT::Periodic::Download-Upgradeable-Packages "0"; APT::Periodic::AutocleanInterval "0"; APT::Periodic::Unattended-Upgrade "0"; # 修改配置 sudo vim /etc/apt/apt.conf.d/20auto-upgrades # 原来是这样的 APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "0"; APT::Periodic::AutocleanInterval "0"; APT::Periodic::Unattended-Upgrade "1"; # 改成这样的 APT::Periodic::Update-Package-Lists "0"; APT::Periodic::Download-Upgradeable-Packages "0"; APT::Periodic::AutocleanInterval "0"; APT::Periodic::Unattended-Upgrade "0";


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有