Ubuntu20.04下安装显卡驱动

环境配置

系统: Ubuntu 20.04
CPU: i5
GPU:Geforce 960M

Ubuntu安装显卡驱动

1、查看当前显卡安装情况

使用glxinfo查看

https://dri.freedesktop.org/wiki/glxinfo/

$ glxinfo
Command 'glxinfo' not found, but can be installed with: 
sudo apt install mesa-utils

需要安装mesa-utils

sudo apt install mesa-utils

查看gl相关命令

$ glxinfo | grep render
direct rendering: Yes 
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)

direct rendering: 返回yes则表示是采用直接渲染,对应no则为非直接渲染(这时渲染指令将发送到X-server中渲染)
OpenGL renderer string:诉你现在用的是什么driver, 能告诉你系统此时用的是software rendering还是hardware rendering

ps:拓展延伸其他情况

# 非直接+硬件渲染
direct rendering: No (LIBGL_ALWAYS_INDIRECT set)
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)

这里 OpenGL通过设置环境变量,被强制使用indirect rendering,意味着所有的rendering commands都被发往 X server。但是 X server实际上用的是硬件加速渲染(hardware accelerated rendering

#直接+软件渲染
direct rendering: Yes
OpenGL renderer string: Software Rasterizer

这里OpenGL味着用的是software rendering,但是所有的software rendering是在client application里完成的,而不是发往 X server

查看OpenGL渲染信息

$ glxinfo | grep OpenGL # glxinfo | grep -i opengl #可忽略大小写
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 21.2.6
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 21.2.6
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 21.2.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:

注意第二行 OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2) 显然OpenGL的渲染采用的核显(也是硬件渲染)

当然,我们可以有更简单的方式,点击桌面的又上角,选择Settings打开About如下图
Ubuntu20.04下安装显卡驱动_第1张图片

如果没有安装显卡,那么可以正式进入下面步骤了

2、查看所有可用的显卡驱动ubuntu-drivers devices

$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd0000139Bsv000017AAsd00003978bc03sc02i00
vendor   : NVIDIA Corporation
model    : GM107M [GeForce GTX 960M]
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-driver-450-server - distro non-free
driver   : nvidia-driver-418-server - distro non-free
driver   : nvidia-driver-525-server - distro non-free
driver   : nvidia-driver-515 - distro non-free
driver   : nvidia-driver-470-server - distro non-free
driver   : nvidia-driver-510 - distro non-free
driver   : nvidia-driver-515-server - distro non-free
driver   : nvidia-driver-525 - distro non-free recommended
driver   : nvidia-driver-470 - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

选择后面有recommend 的驱动

# 安装显卡
sudo apt-get install nvidia-driver-525

或者Win+A打开 APP的Additional Driver
Ubuntu20.04下安装显卡驱动_第2张图片选择第一个推荐的nvidia-driver-525,然后点击Applying Changes
Ubuntu20.04下安装显卡驱动_第3张图片开始安装下载,安装完成后重启电脑

Nvidia官方地址 https://www.nvidia.cn/

使用nvidia-smi命令查看GPU情况

nvida-smi
# 更多 https://blog.csdn.net/youlinhuanyan/article/details/12873409

配置nvidia

# 启动nvida配置窗口
nvidia-settings

Ubuntu20.04下安装显卡驱动_第4张图片可通过prime-select命令设置使用nvidia独显

sudo prime-select nvidia # 其他选项 nvidia | no-demand | intel

其他查看glxinfo

$ glxinfo -B
name of display: :1
display: :1  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Intel Open Source Technology Center (0x8086)
    Device: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2) (0x416)
    Version: 21.2.6
    Accelerated: yes
    Video memory: 1536MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 3.0
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.1
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 21.2.6
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.0 Mesa 21.2.6
OpenGL shading language version string: 1.30
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.1 Mesa 21.2.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10

(待续)

你可能感兴趣的:(ubuntu,nvidia,GPU,OpenGL,Geforce)