I am trying to figure out a good split for the CPU/GPU. Is there a way to monitor the CPU and GPU usage to see where I should make the split?
For CPU usage and system memory, try the
htop command, its very detailed and customizable, if this doesnt work use
top (or rather
apt install htop).
GPU memory usage (amongst many other details) can be seen with
/opt/vc/bin/vcdbg reloc stats. Total memory is at the top and free memory is at the bottom
Regarding the optimum CPU/GPU split. It really depends on what you are using your RPi for. If your not playing videos and games (GPU optimized), then give the CPU the most amount of RAM. Also if your running "headless" (Not connected to a screen) then assign the CPU as much RAM as you can.
Chromium GPU support is deeply dependent on what version of RPi you have and formats. And what you expect to be off loaded to the GPU.
To monitor the RAM usage, you can run
free -h -s 1. Every second (
-s 1), a similar table will be displayed:
total used free shared buffers cached Mem: 438M 146M 292M 0B 15M 102M -/+ buffers/cache: 28M 409M Swap: 99M 0B 99M
Mem: is what you are looking for.
In the example above, you can see that, on a total of 438MB, 146MB are currently used, and 292MB remain free. On my 512MB RPi, I have set 64MB for the GPU.
To monitor the CPU, RAM and SWAP usage in Raspbian, you can use TOP or HTOP.
But, I find HTOP to be more useful, with better details and features available. HTOP is not available by default, and need to be installed.
sudo apt-get update && sudo apt-get install htop in Terminal to install HTOP.
In terminal, run
htop after the install is completed.
Hope that helps.
The command that will give you insight into what's being allocated by the GPU is
sudo vcdbg reloc. The output looks like what begins here. In my case, I could see that the 236M allocated was too close to the value in
gpu_mem=256 so I needed to bump that up a little.
Relocatable heap version 4 found at 0x30000000 total space allocated is 236M, with 234M relocatable, 2.3M legacy and 0 offline 1 legacy blocks of size 2359296 free list at 0x3ad9aaa0 352 free memory in 2 free block(s) largest free block is 320 bytes 0x30000000: legacy block 2.3M 0x30240000: free 320 [ 80] 0x30240140: used 608 (refcount 1 lock count 0, size 540, align 4, data 0x30240160, d0rual) 'GLXX_TEXTURE_T' [ 78] 0x302403a0: used 192 (refcount 1 lock count 0, size 128, align 4, data 0x302403c0, D1rual) 'GLXX_BUFFER_INNER_T.storage'
This question is old, but the accepted answer does not tell how to monitor the GPU usage.
There is a way -- tested only with the closed source broadcom drivers:
# /opt/vc/bin/vcdbg reloc stats Relocatable heap version 4 found at 0x17800000 total space allocated is 116M, with 114M relocatable, 2.3M legacy and 0 offline 1 legacy blocks of size 2359296 small_allocs : 1163 allocs : 6731 alloc_fails : 0 legacy_block_fails : 0 compactions : 0 discard_compactions : 0 aggressive_compactions : 0 aggressive_compaction_waits : 0 aggressive_compaction_timeouts: 0 locks : 0 small_locks : 0 free list at 0x1ebf24e0 86M free memory in 6 free block(s) largest free block is 86M bytes
For more info,
# /opt/vc/bin/vcdbg help Usage: /opt/vc/bin/vcdbg command [args ...] Where command is one of the following: addr2line ADDR [ADDRS...] - Convert addresses to function names bootfs [dump|get [ARGS]] - Commands related to BootFS dump ADDR|SYM [LEN] - Dumps memory (Hex and ASCII) dumpstate - One shot dump of all minimal commands elfsym SYMBOL [SYMBOLS...] - Prints out the values of the indicated ELF-file symbol grep WORD - Search memory for a 32-bit word help [command] - Prints command help information hist - Processes task history log hostmemuse - Dump host memory usage scoreboard image ADDR|HNDL|all W H TYPE - Save image data to file in current directory, with given size and type (8bpp, rgbx32, tf_rgbx32, yuv420, ...) isp_timeout_dump - Dump ISP hardware state after a timeout log COMMAND [ARGS] - Commands related to logging malloc - Report on the VC malloc heap pools [NAME] [images] - Report on vc_pools [optionally save images to files in current directory] reloc [small|stats] - Dump out relocatable heap [or just small, or stats] save FILENAME [ADDR|SYM [LEN]] - Saves the indicated memory (or all) to a file set ADDR|SYM VALUE [VALUES...] - Writes 32-bit words to memory (address, or VC_DEBUG_VAR or ELF symbol) sym SYMBOL - Prints out the values of the indicated VC_DEBUG_VAR symbol syms - Prints out the values of the available VC_DEBUG_VAR symbols trash ADDR [LEN] - Trash VC memory [default: 1 byte] tx - Examine ThreadX state vchiqdump - Examine vchiq state vchiqslot - Examine vchiq slot data version - Print VC firmware version