I have a Lenovo Thikpad P14s with hybrid graphics : integrated Intel GPU and additional nVidia CPU.
I used sudo prime-select intel
to set it to use only the integrated GPU.
There's a BIOS setting to give 256 or 512 MB RAM to the GPU, which I set to 512.
I want to check the real memory usage by the GPU.
Let's check a few things :
$ 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
reports 512 MB, which should be correct.
glxinfo
reports the whole RAM, which is obviously incorrect.
I don't know how to calculate each range's size in lshw
output, but it seems to report the same ranges as lspci -v
.
I also thought about the total memory being less than 16 GB, as reported by the free
command, or if we ask the kernel directly :
grep MemTotal /proc/meminfo
MemTotal: 16015528 kB
The kernel sees 16015528 / 1024 = 15640
total MB
While 16 GB should be 16 * 1024 = 16384
total MB
So 16384 - 15640 = 744
MB are unaccounted for, might this be due to them being reserved by the GPU ? But why 744 instead of 512 ? Are some other memory ranges reserved and not seen by the kernel ?
By the way, I checked that the kernel reports kB as 1024 bytes (see https://superuser.com/questions/1737654/what-is-the-true-meaning-of-the-unit-kb-in-proc-meminfo) and eveything RAM related is usually in powers of 1024 too (as in, 16 GB total should be 16 * 1024 MB).