Efficient Memory Management for GPU-based Deep Learning Systems

Junzhe Zhang, Sai-Ho Yeung, Yao Shu, Bingsheng He, Wei WangarXiv 2019

Introduction

Deep Learning (DL) models are becoming increasingly complex, with architectures like ResNet and VGG growing deeper and wider to achieve state-of-the-art accuracy. However, this growth is frequently constrained by the "memory wall" of modern GPUs. This paper introduces SmartPool and AutoSwap, two system-level, accuracy-transparent techniques designed to optimize GPU memory usage by exploiting the predictable, iterative nature of DL training.

The Memory Challenge

Standard memory management in DL often relies on generic paging or manual data swapping, which can be inefficient or labor-intensive. Model compression is another alternative, but it typically sacrifices accuracy. The authors propose a transparent system that requires no user intervention and maintains model integrity while reducing the memory footprint by up to 34.2%.

Methods: Exploiting Iterative Predictability

The core insight is that DL training is highly predictable. By profiling the first few iterations, the system can map every variable's lifetime and access order, transforming an online memory management problem into an offline optimization task.

SmartPool: Advanced Memory Sharing

SmartPool treats memory allocation as an offline Dynamic Storage Allocation (DSA) problem. Unlike traditional methods that allow only 1-to-1 memory sharing, SmartPool enables multiple smaller variables to reuse the space previously occupied by a single large variable.

SmartPool uses a Best-Fit heuristic to pack variables into memory "holes" over time, maximizing reuse.

By using a "Best-Fit" heuristic, SmartPool packs variables into the memory grid (time vs. location) more efficiently than standard pools, reducing the overall footprint without adding computational overhead.

AutoSwap: Intelligent GPU-CPU Swapping

AutoSwap automatically migrates variables not currently in use to the CPU and fetches them back just before they are needed for computation. To minimize performance impact, these transfers are scheduled in the background using separate CUDA streams.

AutoSwap calculates priority scores to determine which variables to swap out during peak memory load.

The system utilizes several priority scores—Duration of Absence (DOA), Area of Absence (AOA), and Submodular Weighted DOA (SWDOA)—to identify the best candidates for swapping. These scores account for variable size, the duration they can stay on the CPU, and the shifting "peak memory" point. Bayesian Optimization is employed during the initial training phase to tune these scores for the specific model architecture.

Key Results and Insights

The proposed system was evaluated using CIFAR-10 on ResNet and VGG architectures. Key findings include:

  • Efficiency: SmartPool reduced memory footprints by up to 13.3% compared to Nvidia’s CnMem pool.
  • Performance: AutoSwap achieved up to a 34.2% reduction in memory footprint (specifically in ResNet50) with zero communication overhead.
  • Scalability: The effectiveness of these techniques improves as models become deeper, making them well-suited for future large-scale DNNs.

A significant observation is the pattern of back-propagation: variables in the bottom layers are accessed only at the start and end of an iteration, making them ideal candidates for swapping as they can reside on the CPU for most of the training step.

Conclusion

By leveraging the iterative nature of deep learning, SmartPool and AutoSwap provide a robust, automated solution to GPU memory limitations. These techniques allow for the training of larger models on existing hardware without sacrificing accuracy or training speed, effectively pushing back the "memory wall."

Summary updated

BibTeX
@misc{zhang2019efficient,
  author = {Junzhe Zhang and Sai-Ho Yeung and Yao Shu and Bingsheng He and Wei Wang},
  title = {{Efficient Memory Management for GPU-based Deep Learning Systems}},
  year = {2019},
  eprint = {1903.06631},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1903.06631},
}
Figure