Linux/显卡

来自康健生活

返回上一级

检查

glxinfo

确定显卡程序已经安装。

kangjian@kangjian:~/桌面$
glxinfo | grep rendering
direct rendering: Yes
kangjian@kangjian:~/桌面$
glxinfo | grep -i rend
direct rendering: Yes
    GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, 
    Renderbuffer free memory - total: 7686 MB, largest block: 6083 MB
    Renderbuffer free aux. memory - total: 56154 MB, largest block: 42137 MB
OpenGL renderer string: Radeon RX 5500 XT
    GL_ARB_compute_shader, GL_ARB_conditional_render_inverted, 
    GL_NV_conditional_render, GL_NV_copy_depth_to_color, GL_NV_copy_image, 
    GL_ARB_conditional_render_inverted, GL_ARB_conservative_depth, 
    GL_NV_conditional_render, GL_NV_copy_depth_to_color, GL_NV_copy_image, 
    GL_ARB_conditional_render_inverted, GL_ARB_conservative_depth, 
    GL_NV_conditional_render, GL_NV_copy_depth_to_color, GL_NV_copy_image,

lspci

检测显卡驱动版本

kangjian@kangjian:~/桌面$
lspci | grep -i VGA
03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 14 [Radeon RX 5500/5500M / Pro 5500M] (rev c5)


kangjian@kangjian:~/桌面$
lspci | grep -i VGA
03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 14 [Radeon RX 5500/5500M / Pro 5500M] (rev c5)

获取系统上显卡的信息

kangjian@kangjian:~/桌面$
lspci -vnn | grep VGA -A 12
03:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 14 [Radeon RX 5500/5500M / Pro 5500M] [1002:7340] (rev c5) (prog-if 00 [VGA controller])
	Subsystem: Gigabyte Technology Co., Ltd Navi 14 [Radeon RX 5500/5500M / Pro 5500M] [1458:2319]
	Flags: bus master, fast devsel, latency 0, IRQ 165
	Memory at e0000000 (64-bit, prefetchable) [size=256M]
	Memory at f0000000 (64-bit, prefetchable) [size=2M]
	I/O ports at e000 [size=256]
	Memory at f7a00000 (32-bit, non-prefetchable) [size=512K]
	Expansion ROM at 000c0000 [disabled] [size=128K]
	Capabilities: <access denied>
	Kernel driver in use: amdgpu
	Kernel modules: amdgpu

03:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 HDMI Audio [1002:ab38]

当前驱动

kangjian@kangjian:~/桌面$
lshw -c video | grep configuration
WARNING: you should run this program as super-user.
       configuration: driver=amdgpu latency=0
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
 
moreinfo amdgpu


nvidia GPU

查看GPU型号

lspci | grep -i nvidia

查看驱动版本

sudo dpkg --list | grep nvidia-*
ubuntu-drivers devices

安装

 sudo ubuntu-drivers autoinstall

amd GPU

查看GPU型号

kangjian@kangjian:~/桌面$
lspci | grep -i amd
01:00.0 PCI bridge: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 XL Upstream Port of PCI Express Switch (rev c5)
02:00.0 PCI bridge: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 XL Downstream Port of PCI Express Switch
03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 14 [Radeon RX 5500/5500M / Pro 5500M] (rev c5)
03:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 HDMI Audio

查看驱动版本

kangjian@kangjian:~/桌面$
sudo dpkg --list | grep amd-*
ii  accountsservice                            0.6.55-0ubuntu11                      amd64        query and manipulate user account information
...
ii  amd64-microcode                            3.20191218.1ubuntu1                   amd64        Processor microcode firmware for AMD CPUs
ii  amdgpu                                     20.20-1089974                         amd64        Meta package to install amdgpu components.
ii  amdgpu-core                                20.20-1089974                         all          Core meta package for unified amdgpu driver.
ii  amdgpu-dkms                                1:5.6.0.13-1089974                    all          amdgpu driver in DKMS format.
...
ii  zip                                        3.0-11build1                          amd64        Archiver for .zip files
ii  zlib1g:amd64                               1:1.2.11.dfsg-2ubuntu1                amd64        compression library - runtime

风扇控制

 
sudo apt-get install git
git clone https://github.com/dominilux/amdgpu-pro-fans
cd amdgpu-pro-fans
chmod +x amdgpu-pro-fans.sh

使用方法:

 
cd amdgpu-pro-fans
 
sudo ./amdgpu-pro-fans.sh -s [speed 0 – 100]

理论:

进入 /sys/class/drm/card0/device/hwmon/hwmon3

  • To switch to manual fan control from automatic, run
     
    echo "1" > pwm1_enable
    
  • Set up fan speed to e.g. 50% (100% are 255 PWM cycles, thus calculate desired fan speed percentage by multiplying its value by 2.55):
     
    echo "128" > pwm1
    
  • To reset to automatic fan control, run
     
    echo "2" > pwm1_enable
    
  • Warning: Resetting fan speed to auto may not work due to a driver bug and instead a restart of the driver may be required as a workaround.

OpenGL

检查硬件加速。

kangjian@kangjian:~/桌面$
glxinfo | grep OpenGL
OpenGL vendor string: Advanced Micro Devices, Inc.
OpenGL renderer string: Radeon RX 5500 XT
OpenGL core profile version string: 4.6.14736 Core Profile Context 20.20
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.14736 Compatibility Profile Context 20.20
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: 4.6.14736 Compatibility Profile Context 20.20
OpenGL ES profile shading language version string: 4.60
OpenGL ES profile extensions:

AMD

驱动

安装驱动。

 
./amdgpu-pro-install -y

安装 radeontop 显示 AMD GPU 使用情况

 
sudo apt install radeontop
 
sudo radeontop
Linux 显卡 amd GPU radeontop 1
Linux 显卡 amd GPU radeontop 1

这里可以看到显卡有些不正常,目前还不知道解决办法。

Nvidia

显卡

查看显卡

lspci -nn | grep VGA
00:02.0 VGA compatible controller [0300]: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller [8086:0116] (rev 09)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF108M [GeForce GT 555M] [10de:0deb] (rev a1)
运行powerstat观察电池的放电功率(安装 powerstat : sudo apt install powerstat)。
powerstat -d 0
Running for 480.0 seconds (48 samples at 10.0 second intervals).
Power measurements will start in 0 seconds time.

  Time    User  Nice   Sys  Idle    IO  Run Ctxt/s  IRQ/s Fork Exec Exit  Watts
20:46:23   1.3   0.0   0.2  98.5   0.1    1    182    144    1    0    5   2.26 
20:46:33   0.0   0.0   0.0  99.9   0.0    1     78    114    0    0    0   2.20 
20:46:43   0.2   0.0   0.1  99.7   0.1    1    136    126    0    0    0   2.19 
20:46:53   0.1   0.0   0.0  99.9   0.0    1     75    112    0    0    0   2.18 
20:47:03   0.3   0.0   0.1  99.6   0.1    1    137    131    0    0    0   2.18 
20:47:13   0.1   0.0   0.0  99.9   0.1    1     86    113    0    0    0   2.18 
20:47:23   0.2   0.0   0.1  99.7   0.0    1    128    122    0    0    1   2.18 
20:47:33   0.1   0.0   0.0  99.9   0.0    1     73    110    0    0    0   2.18 
20:47:43   0.2   0.0   0.1  99.7   0.0    1    130    123    0    0    0   2.18 
20:47:53   0.1   0.0   0.0  99.9   0.0    1     75    110    0    0    0   2.18 
20:48:03   0.2   0.0   0.1  99.7   0.1    1    127    122    0    0    2   2.19 
20:48:13   0.0   0.0   0.0  99.9   0.0    1     83    113    1    0    2   2.18 
20:48:23   1.1   0.0   0.3  98.6   0.1    1    933    310    2    0    0   2.22 
-------- ----- ----- ----- ----- ----- ---- ------ ------ ---- ---- ---- ------ 
 Average   0.3   0.0   0.1  99.6   0.0  1.0  172.6  134.7  0.3  0.0  0.8   2.19 
  StdDev   0.4   0.0   0.1   0.5   0.0  0.0  222.0   51.4  0.6  0.0  1.4   0.02 
-------- ----- ----- ----- ----- ----- ---- ------ ------ ---- ---- ---- ------ 
 Minimum   0.0   0.0   0.0  98.5   0.0  1.0   73.2  110.0  0.0  0.0  0.0   2.18 
 Maximum   1.3   0.0   0.3  99.9   0.1  1.0  933.2  309.8  2.0  0.0  5.0   2.26 
-------- ----- ----- ----- ----- ----- ---- ------ ------ ---- ---- ---- ------ 
Summary:
System:   2.19 Watts on average with standard deviation 0.02  

查看操作系统的发行版号

uname -r
4.9.0-3-amd64

依然查看显卡收集信息

sudo lspci -knn
00:00.0 Host bridge [0600]: Intel Corporation 2nd Generation Core Processor Family DRAM Controller [8086:0104] (rev 09)
	Subsystem: Lenovo 2nd Generation Core Processor Family DRAM Controller [17aa:3975]
00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port [8086:0101] (rev 09)
	Kernel driver in use: pcieport
	Kernel modules: shpchp
00:02.0 VGA compatible controller [0300]: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller [8086:0116] (rev 09)
	Subsystem: Lenovo 2nd Generation Core Processor Family Integrated Graphics Controller [17aa:3981]
	Kernel driver in use: i915
	Kernel modules: i915
00:16.0 Communication controller [0780]: Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 [8086:1c3a] (rev 04)
	Subsystem: Lenovo 6 Series/C200 Series Chipset Family MEI Controller [17aa:3975]
	Kernel driver in use: mei_me
	Kernel modules: mei_me
00:1a.0 USB controller [0c03]: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 [8086:1c2d] (rev 05)
	Subsystem: Lenovo 6 Series/C200 Series Chipset Family USB Enhanced Host Controller [17aa:3975]
	Kernel driver in use: ehci-pci
	Kernel modules: ehci_pci
00:1b.0 Audio device [0403]: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller [8086:1c20] (rev 05)
	Subsystem: Lenovo 6 Series/C200 Series Chipset Family High Definition Audio Controller [17aa:3975]
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel
00:1c.0 PCI bridge [0604]: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 [8086:1c10] (rev b5)
	Kernel driver in use: pcieport
	Kernel modules: shpchp
00:1c.1 PCI bridge [0604]: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 [8086:1c12] (rev b5)
	Kernel driver in use: pcieport
	Kernel modules: shpchp
00:1c.4 PCI bridge [0604]: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 5 [8086:1c18] (rev b5)
	Kernel driver in use: pcieport
	Kernel modules: shpchp
00:1d.0 USB controller [0c03]: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 [8086:1c26] (rev 05)
	Subsystem: Lenovo 6 Series/C200 Series Chipset Family USB Enhanced Host Controller [17aa:3975]
	Kernel driver in use: ehci-pci
	Kernel modules: ehci_pci
00:1f.0 ISA bridge [0601]: Intel Corporation HM65 Express Chipset Family LPC Controller [8086:1c49] (rev 05)
	Subsystem: Lenovo HM65 Express Chipset Family LPC Controller [17aa:3975]
	Kernel driver in use: lpc_ich
	Kernel modules: lpc_ich
00:1f.2 SATA controller [0106]: Intel Corporation 6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller [8086:1c03] (rev 05)
	Subsystem: Lenovo 6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller [17aa:3975]
	Kernel driver in use: ahci
	Kernel modules: ahci
00:1f.3 SMBus [0c05]: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller [8086:1c22] (rev 05)
	Subsystem: Lenovo 6 Series/C200 Series Chipset Family SMBus Controller [17aa:3975]
	Kernel driver in use: i801_smbus
	Kernel modules: i2c_i801
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF108M [GeForce GT 555M] [10de:0deb] (rev a1)
	Subsystem: Lenovo GF108M [GeForce GT 555M] [17aa:3981]
	Kernel driver in use: nouveau
	Kernel modules: nouveau
07:00.0 Ethernet controller [0200]: Broadcom Limited NetLink BCM57781 Gigabit Ethernet PCIe [14e4:16b1] (rev 10)
	Subsystem: Lenovo NetLink BCM57781 Gigabit Ethernet PCIe [17aa:3975]
	Kernel driver in use: tg3
	Kernel modules: tg3
08:00.0 Network controller [0280]: Intel Corporation Centrino Wireless-N 1000 [Condor Peak] [8086:0084]
	Subsystem: Intel Corporation Centrino Wireless-N 1000 BGN [8086:1315]
	Kernel modules: iwlwifi
09:00.0 System peripheral [0880]: JMicron Technology Corp. SD/MMC Host Controller [197b:2392] (rev 30)
	Subsystem: Lenovo SD/MMC Host Controller [17aa:3976]
	Kernel driver in use: sdhci-pci
	Kernel modules: sdhci_pci
09:00.2 SD Host controller [0805]: JMicron Technology Corp. Standard SD Host Controller [197b:2391] (rev 30)
	Subsystem: Lenovo Standard SD Host Controller [17aa:3976]
	Kernel modules: sdhci_pci
09:00.3 System peripheral [0880]: JMicron Technology Corp. MS Host Controller [197b:2393] (rev 30)
	Subsystem: Lenovo MS Host Controller [17aa:3976]
	Kernel driver in use: jmb38x_ms
	Kernel modules: jmb38x_ms
09:00.4 System peripheral [0880]: JMicron Technology Corp. xD Host Controller [197b:2394] (rev 30)
	Subsystem: Lenovo xD Host Controller [17aa:3976]

查看硬件信息(sudo apt-get install lshw lshw-gtk)。

sudo lshw -numeric -class video
  *-display                 
       description: VGA compatible controller
       product: GF108M [GeForce GT 555M] [10DE:DEB]
       vendor: NVIDIA Corporation [10DE]
       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:27 memory:f0000000-f0ffffff memory:c0000000-cfffffff memory:d0000000-d1ffffff ioport:2000(size=128) memory:f1000000-f107ffff
  *-display
       description: VGA compatible controller
       product: 2nd Generation Core Processor Family Integrated Graphics Controller [8086:116]
       vendor: Intel Corporation [8086]
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 09
       width: 64 bits
       clock: 33MHz
       capabilities: msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:29 memory:f1400000-f17fffff memory:e0000000-efffffff ioport:3000(size=64) memory:c0000-dffff

以上仅限信息分析,接下来安装BUNBLEBEE

确定系统架构内核

sudo dpkg --print-architecture
amd64

确认是否打开了多架构支持功能

sudo dpkg --print-foreign-architectures
i386

安装32位支持

sudo dpkg --add-architecture i386
sudo apt -get update

检查已拥有的库文件是否有更新的版本

sudo apt-get dist-upgrade

安装bumblebee

sudo apt-get install bumblebee primus primus-libs:i386

如果要运行闭源驱动继续下一步,如果想用nouveau开源驱动跳过下一步

sudo apt-get install bumblebee-nvidia primus

添加用户组

sudo adduser $USER bumblebee

再次查看显卡(末尾rev ff表示已关闭)

lspci -nn | grep VGA
00:02.0 VGA compatible controller [0300]: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller [8086:0116] (rev 09)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF108M [GeForce GT 555M] [10de:0deb] (rev ff)

再测耗电功率

powerstat -d 0
Running for 480.0 seconds (48 samples at 10.0 second intervals).
Power measurements will start in 0 seconds time.

  Time    User  Nice   Sys  Idle    IO  Run Ctxt/s  IRQ/s  Watts
13:41:07   0.3   0.0   0.1  99.6   0.0    1    145     68   1.13 
13:41:17   0.1   0.0   0.0  99.8   0.1    1     79     51   1.13 
13:41:27   0.2   0.0   0.1  99.7   0.1    1    131     60   1.14 
13:41:37   0.1   0.0   0.0  99.9   0.0    1     80     52   1.13 
13:41:47   0.2   0.0   0.1  99.7   0.1    1    126     58   1.14 
^C-------- ----- ----- ----- ----- ----- ---- ------ ------ ------ 
 Average   0.2   0.0   0.0  99.8   0.0  1.0  112.1   57.9   1.13 
  StdDev   0.1   0.0   0.0   0.1   0.0  0.0   27.5    6.1   0.00 
-------- ----- ----- ----- ----- ----- ---- ------ ------ ------ 
 Minimum   0.1   0.0   0.0  99.6   0.0  1.0   78.8   51.3   1.13 
 Maximum   0.3   0.0   0.1  99.9   0.1  1.0  145.2   68.1   1.14 
-------- ----- ----- ----- ----- ----- ---- ------ ------ ------ 
Summary:
System:   1.13 Watts on average with standard deviation 0.00  

温度和风速

lm-sensors

sudo apt-get install lm-sensors
kangjian@kangjian:~/桌面$
sensors
coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +32.0°C  (high = +82.0°C, crit = +100.0°C)
Core 0:        +32.0°C  (high = +82.0°C, crit = +100.0°C)
Core 1:        +32.0°C  (high = +82.0°C, crit = +100.0°C)
Core 2:        +31.0°C  (high = +82.0°C, crit = +100.0°C)
Core 3:        +31.0°C  (high = +82.0°C, crit = +100.0°C)
Core 4:        +32.0°C  (high = +82.0°C, crit = +100.0°C)
Core 5:        +31.0°C  (high = +82.0°C, crit = +100.0°C)

acpitz-acpi-0
Adapter: ACPI interface
temp1:        +27.8°C  (crit = +119.0°C)
temp2:        +29.8°C  (crit = +119.0°C)

amdgpu-pci-0300
Adapter: PCI adapter
vddgfx:      706.00 mV 
fan1:           0 RPM  (min =    0 RPM, max = 3400 RPM)
edge:         +49.0°C  (crit = +113.0°C, hyst = -273.1°C)
                       (emerg = +99.0°C)
junction:     +51.0°C  (crit = +99.0°C, hyst = -273.1°C)
                       (emerg = +99.0°C)
mem:          +50.0°C  (crit = +99.0°C, hyst = -273.1°C)
                       (emerg = +99.0°C)
power1:       16.00 W  (cap = 125.00 W)

watch

配合 watch命令,可以每秒执行一次。

 
watch -n 1 sensors

psensor

图形化的硬件温度传感器的监控工具,基于 Linux 的 lm-sensors 和 GTK 库。

  • 显示主板和CPU温度(利用LM-传感器)
  • 显示NVIDIA GPU(使用XNVCtrl)显卡温度
  • 显示硬盘驱动器(使用hddtemp)温度
  • 显示风扇(利用LM-传感器)转速
 
sudo apt-add-repository ppa:jfi/psensor-unstable
sudo apt-get update
sudo apt-get install psensor