Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_subdirectory(pinctrl)
add_subdirectory(piolib)
add_subdirectory(raspinfo)
add_subdirectory(rpieepromab)
add_subdirectory(rpi-gpu-usage)
add_subdirectory(vcgencmd)
add_subdirectory(vclog)
add_subdirectory(vcmailbox)
Expand Down
14 changes: 14 additions & 0 deletions rpi-gpu-usage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.10...3.27)

include(GNUInstallDirs)

project(rpi-gpu-usage)

find_package(Curses REQUIRED)

add_executable(rpi-gpu-usage rpi-gpu-usage.c)
target_include_directories(rpi-gpu-usage PRIVATE ${CURSES_INCLUDE_DIRS})
target_link_libraries(rpi-gpu-usage ${CURSES_LIBRARIES})
install(TARGETS rpi-gpu-usage RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES rpi-gpu-usage.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES rpi-gpu-usage-completion.bash RENAME rpi-gpu-usage DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions")
49 changes: 49 additions & 0 deletions rpi-gpu-usage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

# rpi-gpu-usage

rpi-gpu-usage is a simple tool for showing the per-process usage of the V3D
GPU on Raspberry Pi 4 and 5. It works by parsing the /proc/\*/fdinfo/\*
information to find the processes that have drm stats information like:

```
/proc/2390/fdinfo/23:drm-driver: v3d
/proc/2390/fdinfo/23:drm-client-id: 14
/proc/2390/fdinfo/23:drm-engine-bin: 25951428711 ns
/proc/2390/fdinfo/23:drm-engine-render: 1400777565939 ns
/proc/2390/fdinfo/23:drm-engine-tfu: 26324241848 ns
/proc/2390/fdinfo/23:drm-engine-csd: 0 ns
/proc/2390/fdinfo/23:drm-engine-cache_clean: 0 ns
/proc/2390/fdinfo/23:drm-engine-cpu: 0 ns
/proc/2390/fdinfo/23:drm-total-memory: 74864 KiB
/proc/2390/fdinfo/23:drm-shared-memory: 31600 KiB
/proc/2390/fdinfo/23:drm-active-memory: 0
/proc/2390/fdinfo/23:drm-resident-memory: 43264 KiB
/proc/2390/fdinfo/23:drm-purgeable-memory: 0
```

The application then outputs total GPU usage for the renderer (shaders)
tfu (texture format unit) and binning blocks. It also reads the total CPU
usage for that process.

```
GPU Utilisation

Client PID Process render tfu bin CPU
----------------------------------------------------------------------
14 2215 labwc 13.2% 0.0% 0.3% 18.7%
38 10668 chromium 0.0% 0.0% 0.0% 0.0%
```

**Command line options**

* --csv Output in CSV format. This can just be cat'ed to a file for analysis


**Build Instructions**

Install the prerequisites with "sudo apt install cmake libncurses-dev" - you need at least version 3.10 of cmake. Run the following commands, either here or in the top-level directory to build and install everything:

- *cmake .*
- *make*
- *sudo make install*

7 changes: 7 additions & 0 deletions rpi-gpu-usage/rpi-gpu-usage-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_rpi_gpu_usage() {
local cur prev words cword
_init_completion || return
COMPREPLY=($(compgen -W "--csv --help" -- "$cur"))
}

complete -F _rpi_gpu_usage rpi-gpu-usage
29 changes: 29 additions & 0 deletions rpi-gpu-usage/rpi-gpu-usage.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.TH RPI-GPU-USAGE 1 "2025" "raspi-utils" "Raspberry Pi Utilities"
.SH NAME
rpi-gpu-usage \- monitor VideoCore GPU block utilisation
.SH SYNOPSIS
.B rpi-gpu-usage
.RI [ options ]
.SH DESCRIPTION
.B rpi-gpu-usage
monitors the VideoCore GPU block utilisation on Raspberry Pi 4/5.
It reads per-process GPU engine times from DRM fdinfo and global
utilisation from the V3D gpu_stats sysfs interface.
.PP
The display is refreshed once per second, showing per-client
GPU engine usage (render, tfu, bin) and CPU usage.
.SH OPTIONS
.TP
.B \-\-csv
Output in CSV format instead of a formatted table.
Suitable for piping to a file for later analysis.
.TP
.B \-\-help
Show usage information and exit.
.SH EXAMPLES
.nf
sudo rpi-gpu-usage # interactive terminal display
sudo rpi-gpu-usage --csv > gpu.csv # log CSV to file
.fi
.SH SEE ALSO
.BR vcgencmd (1)
Loading