Pinpointing the Memory Behaviors of DNN Training

Jiansong Li, Xiao Dong, Guangli Li, Peng Zhao, Xueying Wang, Xiaobing Chen, Xianzhi Yu, Yongxin Yang, Zihan Jiang, Wei Cao, Lei Liu, Xiaobing Feng

Introduction

As deep learning models continue to scale in depth and width, they increasingly encounter the "memory wall"—the physical capacity limits of GPU accelerators. While computational throughput has seen exponential growth, memory capacity has lagged, often forcing researchers to reduce batch sizes or use simpler models. For instance, training Inception-V4 can require up to 45GB of VRAM, exceeding the 40GB capacity of high-end GPUs like the Nvidia Ampere. To overcome this, data swapping between GPU and host CPU RAM is a common strategy, but "blind" swapping often leads to significant performance degradation. This study introduces a granular, block-by-block analysis of memory access patterns to identify optimal candidates for offloading.

Methodology

The researchers instrumented the memory allocators within the PyTorch runtime system to track four fundamental operations for every device memory block: malloc, free, read, and write. A central metric in this analysis is the Access Time Interval (ATI), defined as the elapsed time between two consecutive accesses to the same memory block. By correlating ATIs with block sizes, the study characterizes the "lifetime" and "idleness" of data. The distribution of these intervals was analyzed across various models (including ResNet, AlexNet, and RNNs) and datasets (CIFAR-100, ImageNet) using an Nvidia Titan X Pascal GPU.

Characterizing Memory Access Patterns

A key finding is the remarkable stability of memory access patterns in DNN training. The iterative nature of training allows for highly accurate predictions of future memory behavior based on the initial iterations.

Distribution of Access Time Intervals (ATI) showing that most blocks have short idle times, while a few outliers present optimization opportunities.

Analysis of the ATI distribution reveals a critical threshold: approximately 90% of memory blocks have an ATI of less than 25 microseconds. Swapping these blocks is counterproductive, as the overhead of data transfer exceeds the idle time. However, the study identifies "outlier" blocks—typically large intermediate results exceeding 600MB—with ATIs greater than 0.8 seconds. These represent the primary targets for memory optimization via offloading.

Memory Occupation and Scaling

The study further investigates the composition of the memory footprint. While model parameters (weights) are often perceived as the primary memory consumers, they actually occupy a relatively small and constant fraction of the total footprint.

Memory occupation breakdown across different batch sizes, illustrating the dominance of intermediate results (activations) as batch size increases.

As shown in the breakdown for models like AlexNet, intermediate results (activations) quickly scale to dominate memory consumption as batch sizes increase. For identified outlier blocks with long ATIs, the researchers calculated that up to 2.54GB of data could be swapped to host memory without sacrificing training performance, compared to only ~79KB for typical small blocks.

Conclusion and Future Directions

By "pinpointing" specific memory behaviors, this research demonstrates that the GPU memory wall can be breached through selective, data-driven swapping. The identification of high-ATI, large-scale intermediate results provides a clear roadmap for optimization. Future work involves developing an automatic cost model to dynamically handle the offloading process, enabling the training of massive models on modest hardware with minimal runtime overhead.

Summary updated

BibTeX
@inproceedings{li2021pinpointing,
  author = {Jiansong Li and Xiao Dong and Guangli Li and Peng Zhao and Xueying Wang and Xiaobing Chen and Xianzhi Yu and Yongxin Yang and Zihan Jiang and Wei Cao and Lei Liu and Xiaobing Feng},
  title = {{Pinpointing the Memory Behaviors of DNN Training}},
  booktitle = {ISPASS},
  year = {2021},
  doi = {10.1109/ispass51385.2021.00038},
}
Figure