ubuntu 18.04 英伟达显卡驱动

本文档详细介绍了如何在Ubuntu 18.04系统中识别并安装NVIDIA独立显卡驱动。首先通过`glxinfo`、`lspci`和`lshw -C display`命令检查当前显卡信息,发现系统使用的是集成显卡驱动nouveau。接着,通过编辑`blacklist.conf`禁用nouveau,更新系统并选择附加驱动进行安装。成功安装后,`nvidia-smi`命令显示NVIDIA驱动已生效,确认使用的是 GeForce GTX 1660 显卡。此外,还提供了`ubuntu-drivers devices`命令来查看可用的NVIDIA驱动选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、显卡信息

1、glxinfo |grep OpenGL

安装了了英伟达独立显卡,依照下边OpenGL信息OpenGL renderer string: llvmpipe (LLVM 10.0.0, 256 bits)来看,我们安装了英伟达独立显卡,此时却使用的是集成显卡。

123@123-OptiPlex-7071:~$ glxinfo |grep OpenGL
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 10.0.0, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 20.1.0
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.1 Mesa 20.1.0
OpenGL shading language version string: 1.40
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 20.1.0
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:

2、 lspci -vnn | grep VGA -A 12

查看显卡信息,从显卡信息来看,NVIDIA显卡并没有识别出具体的型号,且显卡驱动使用的是nouveau:

123@123-OptiPlex-7071:~$ lspci -vnn | grep VGA -A 12
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation Device [10de:2184] (rev a1) (prog-if 00 [VGA controller])
    Subsystem: Device [7377:0000]
    Flags: bus master, fast devsel, latency 0, IRQ 131
    Memory at a4000000 (32-bit, non-prefetchable) [size=16M]
    Memory at 90000000 (64-bit, prefetchable) [size=256M]
    Memory at a0000000 (64-bit, prefetchable) [size=32M]
    I/O ports at 3000 [size=128]
    Expansion ROM at 000c0000 [disabled] [size=128K]
    Capabilities: <access denied>
    Kernel driver in use: nouveau
    Kernel modules: nvidiafb, nouveau

01:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:1aeb] (rev a1)

3、 sudo lshw -C display

查看硬件的显示信息,从下边可以看出,显示1为英伟达显卡,驱动使用的是nouveau;显示2为Intel Corporation的集成显卡,驱动为driver=i915

123@123-OptiPlex-7071:~$ sudo lshw -C display
  *-display                 
       description: VGA compatible controller
       product: NVIDIA Corporation
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
       configuration: driver=nouveau latency=0
       resources: irq:131 memory:a4000000-a4ffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:3000(size=128) memory:c0000-dffff
  *-display
       description: Display controller
       product: Intel Corporation
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 02
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm bus_master cap_list
       configuration: driver=i915 latency=0
       resources: irq:132 memory:a3000000-a3ffffff memory:80000000-8fffffff ioport:4000(size=64)

4、modinfo 

查看nouveau驱动的详细信息,filename:       /lib/modules/5.4.0-45-generic/kernel/drivers/gpu/drm/nouveau/nouveau.ko可以看出系统内核驱动:

123@123-OptiPlex-7071:~$ sudo modinfo nouveau
file

### 如何在 Ubuntu 18.04 上安装 NVIDIA 显卡驱动 #### 查看适合的显卡驱动版本 为了确保安装最适合系统的NVIDIA驱动,在终端执行命令来检测推荐的驱动版本: ```bash ubuntu-drivers devices ``` 这条命令会列出适用于当前硬件环境的最佳驱动选项[^2]。 #### 禁用 Nouveau 驱动程序 由于默认情况下Ubuntu使用开源的Nouveau驱动管理NVIDIA GPU,这可能会与专有的NVIDIA驱动冲突。因此建议先禁用它。编辑`/etc/modprobe.d/blacklist.conf`文件加入如下两行以阻止加载Nouveau模块: ```plaintext blacklist nouveau options nouveau modeset=0 ``` 保存更改后运行以下指令刷新初始化内存映像并重启计算机: ```bash sudo update-initramfs -u reboot ``` 确认Nouveau已经被成功禁用可以通过查询已载入内核模块列表完成: ```bash lsmod | grep nouveau ``` 如果没有任何输出,则表示操作无误[^4]。 #### 使用 PPA 安装官方稳定版驱动 一种简便的方法是从PPA仓库获取最新的图形驱动支持包。通过向软件源添加由Graphics Drivers团队维护的安全第三方库可获得更频繁更新的服务端口: ```bash sudo add-apt-repository ppa:graphics-drivers/ppa sudo apt-get update ``` 之后可以根据之前查找到的信息选择合适的版本号进行安装,比如对于某些特定型号可能适用的是 `nvidia-driver-xxx` 形式的命名方式(其中 xxx 是具体版本编号)。通常可以直接采用自动匹配最佳候选者的方式简化流程: ```bash sudo ubuntu-drivers autoinstall ``` 此过程将会下载并配置所需的组件到系统当中去[^3]。 #### 手动安装二进制分发包 当需要测试尚未被纳入公共存储库的新特性或是遇到特殊需求时可以选择直接从官方网站取得独立发行档来进行部署。假设已经取得了名为 `NVIDIA-Linux-x86_64-version.run` 的自解压脚本形式发布件,那么应当赋予其执行权限再启动安装进程: ```bash sudo chmod a+x NVIDIA-Linux-x86_64-version.run sudo sh ./NVIDIA-Linux-x86_64-version.run --silent --dkms ``` 注意这里的参数组合能够帮助绕过一些常见的兼容性检查从而顺利完成整个设置工作流。 最后一步总是要记得重新引导机器以便让新的改动生效,并可通过查看X服务器日志或者利用 `nvidia-smi` 工具检验是否一切正常运作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值