liveBook · Manning

Memory usage

As explained in Graph Neural Networks in Action

The amount or proportion of available memory consumed by a computation.

Memory usage is the amount of RAM or processor memory a computation consumes. It is a practical limit on GNN training: a graph that does not fit in available memory can slow a system or cause it to crash. Track it alongside time per epoch and time to convergence when deciding whether a workload will scale. section 7.2.3 section 7.2.2 section 7.0

Start with the graph’s stored data. Node features, edge features, and adjacency matrices all require memory; larger graphs and higher-dimensional features increase demand. Dataset size alone is therefore not a complete memory estimate. section 7.2.3

Make memory a planning and benchmarking check:

  • Estimate dataset size for each phase and check the available hardware. A planning rule of thumb is memory capacity 4–10 times the dataset size. section 7.3.2
  • Run a representative workload and record memory utilization as a baseline. Watch for usage approaching capacity rather than waiting for a slowdown or crash. section 7.3.2 section 7.2.2
  • If capacity is a constraint, consider processor choice, sparse representation, GNN algorithm choice, sampling-based batches, remote backends, or graph coarsening. section 7.0

Measure the memory in use

For process RAM, `psutil.Process(os.getpid()).memory_info().rss` returns resident set size: the portion of the process held in RAM. For an NVIDIA GPU, initialize `pynvml`, obtain a device handle, and read `pynvml.nvmlDeviceGetMemoryInfo(handle).used`. These measurements distinguish process RAM from used GPU memory. section 7.2.3

How Graph Neural Networks in Action covers it

How deep it goes
Defines memory usage, identifies graph storage demands, and shows monitoring methods; stops short of a complete memory budget.
Examples
Measures process resident set size with psutil and used NVIDIA GPU memory with pynvml.
What you can do after
Diagnose/debug with psutil and pynvml by measuring memory use before choosing a scaling strategy.
How it connects
Links memory usage to node features, edge features, adjacency matrices, sampling-based batching, and sparse representation.

Also explained in

Compare how 7 books explain memory usage →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.