我有一台带有混合显卡的联想 Thikpad P14s:集成英特尔 GPU 和额外的 nVidia CPU。
我曾经sudo prime-select intel
将其设置为仅使用集成 GPU。
BIOS 设置可以为 GPU 提供 256 或 512 MB RAM,我将其设置为 512。
我想检查 GPU 的实际内存使用情况。
让我们检查一下以下几点:
$ prime-select query
intel
$ lspci |grep VGA
00:02.0 VGA compatible controller: Intel Corporation CometLake-U GT2 [UHD Graphics] (rev 02)
$ sudo lspci -v -s 00:02.0
00:02.0 VGA compatible controller: Intel Corporation CometLake-U GT2 [UHD Graphics] (rev 02) (prog-if 00 [VGA controller])
Subsystem: Lenovo CometLake-U GT2 [UHD Graphics]
Flags: bus master, fast devsel, latency 0, IRQ 158
Memory at e2000000 (64-bit, non-prefetchable) [size=16M]
Memory at 80000000 (64-bit, prefetchable) [size=512M]
I/O ports at 4000 [size=64]
Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
Capabilities: [40] Vendor Specific Information: Len=0c <?>
Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Capabilities: [100] Process Address Space ID (PASID)
Capabilities: [200] Address Translation Service (ATS)
Capabilities: [300] Page Request Interface (PRI)
Kernel driver in use: i915
Kernel modules: i915
$ glxinfo | grep -E 'Device:|Video memory:'
Device: Mesa Intel(R) UHD Graphics (CML GT2) (0x9b41)
Video memory: 15640MB
$ sudo lshw -C display
*-display
description: VGA compatible controller
product: CometLake-U GT2 [UHD Graphics]
vendor: Intel Corporation
physical id: 2
bus info: pci@0000:00:02.0
logical name: /dev/fb0
version: 02
width: 64 bits
clock: 33MHz
capabilities: pciexpress msi pm vga_controller bus_master cap_list rom fb
configuration: depth=32 driver=i915 latency=0 resolution=2560,1440
resources: irq:158 memory:e2000000-e2ffffff memory:80000000-9fffffff ioport:4000(size=64) memory:c0000-dffff
*-display UNCLAIMED
description: 3D controller
product: GP108GLM [Quadro P520]
vendor: NVIDIA Corporation
physical id: 0
bus info: pci@0000:2d:00.0
version: a1
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list
configuration: latency=0
resources: memory:e1000000-e1ffffff memory:c0000000-cfffffff memory:d0000000-d1ffffff ioport:3000(size=128)
lspci -v
报告 512 MB,这应该是正确的。
glxinfo
报告整个RAM,这显然是不正确的。
我不知道如何计算lshw
输出中每个范围的大小,但它似乎报告了相同的范围lspci -v
。
我还考虑过总内存小于 16 GB,正如命令所报告的那样free
,或者我们直接询问内核:
grep MemTotal /proc/meminfo
MemTotal: 16015528 kB
内核查看16015528 / 1024 = 15640
总 MB
虽然 16 GB 应该是16 * 1024 = 16384
总 MB
因此16384 - 15640 = 744
MB 下落不明,这可能是由于它们被 GPU 保留了?但为什么是 744 而不是 512?是否有其他内存范围被保留且内核看不到?
顺便说一下,我检查了内核将 kB 报告为 1024 字节(参见https://superuser.com/questions/1737654/what-is-the-true-meaning-of-the-unit-kb-in-proc-meminfo) 并且与 RAM 相关的所有东西通常也都是 1024 的幂(例如,16 GB 总共应该是 16 * 1024 MB)。