devutils/ATFQ/book ATFQ git

Part II · Your system

25. GPU

hub

Which graphics chip you have, which driver runs it, and whether programs can use it.

On your machine

alice@laptopexample
$ atfq gpu
  card0     Intel, driver i915, shows the boot screen
  Screens   eDP-1 1920x1200 · free: DP-1, HDMI-A-1
  Compute   /dev/dri/renderD128

An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.

Commands

lspci -k | grep -A3 -E 'VGA|3D'
GPUs and the kernel driver each uses 5.2
glxinfo -B
OpenGL renderer: your GPU, or llvmpipe for software (mesa-utils) 5.2
vulkaninfo --summary
Vulkan devices and drivers
nvidia-smi
NVIDIA: use, memory, processes, driver and CUDA version 5.4
echo $XDG_SESSION_TYPE
wayland or x11 5.3

Paths

/sys/class/drm/
graphics cards and their screen outputs
/dev/dri/
card* to drive screens, renderD* to draw and compute

Also about this

  1. 5.1What a GPU does differentlyA CPU has a few powerful cores, built to run one thread fast, branches and all. A GPU has thousands of simple ones, built to run the same instructions on huge amounts of data at once.
  2. 5.2GPU drivers: the kernel, Mesa and NVIDIAA GPU driver has two halves: a kernel driver (DRM) that owns the device and its memory, and a user-space library that turns OpenGL or Vulkan calls into GPU commands.
  3. 5.3How a picture reaches the screen: KMS, Wayland and X11The kernel sets up the screen itself (KMS: kernel mode setting): resolution, refresh rate, which output shows which image.
  4. 5.4Computing on the GPU, and when your program can't see itCompute frameworks talk to the GPU through a vendor stack: CUDA for NVIDIA, ROCm (HIP) for AMD, oneAPI for Intel. Vulkan and OpenCL work across vendors.