admin 管理员组文章数量: 887021
环境配置
系统: Ubuntu 20.04
CPU: i5
GPU:Geforce 960M
Ubuntu安装显卡驱动
1、查看当前显卡安装情况
使用glxinfo查看
https://dri.freedesktop/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
如下图
如果没有安装显卡,那么可以正式进入下面步骤了
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
选择第一个推荐的nvidia-driver-525
,然后点击Applying Changes
开始安装下载,安装完成后重启电脑
Nvidia官方地址 https://www.nvidia/
使用nvidia-smi命令查看GPU情况
$ nvidia-smi
Sun Feb 5 16:09:29 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.78.01 Driver Version: 525.78.01 CUDA Version: 12.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 Off | N/A |
| N/A 35C P8 N/A / N/A | 8MiB / 2048MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 888 G /usr/lib/xorg/Xorg 2MiB |
| 0 N/A N/A 1483 G /usr/lib/xorg/Xorg 2MiB |
+-----------------------------------------------------------------------------+
注意,上面的CUDA Version: 12.0 并不是指当前安装的cuda版本,而是支持的最高版本的cuda版本
配置nvidia
# 启动nvida配置窗口
nvidia-settings
可通过prime-select
命
其他查看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
通过查看OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)
可知,显卡安装完成后,默认还是用的核显,可以通过下面命令,首选独显
令设置使用nvidia独显
sudo prime-select nvidia # 其他选项 nvidia | no-demand | intel
再次用命令glxinfo
查看OpenGL renderer string
中变为显卡的描述
如未切换过来,可以尝试重启计算机
本文标签: 显卡驱动
版权声明:本文标题:Ubuntu20.04下安装显卡驱动 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1723939623h745661.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论