[Paper Review] Profile-guided memory optimization for deep neural networks
This paper proposes a profile-guided memory optimization for deep neural networks (DNNs) that reduces peak memory usage by up to 49.5% through a fast heuristic-based memory allocation strategy derived from profiling a single forward pass. The method accelerates both training and inference by up to fourfold by enabling faster memory allocation and larger mini-batch sizes, with no runtime performance overhead after profiling.
Recent years have seen deep neural networks (DNNs) becoming wider and deeper to achieve better performance in many applications of AI. Such DNNs however require huge amounts of memory to store weights and intermediate results (e.g., activations, feature maps, etc.) in propagation. This requirement makes it difficult to run the DNNs on devices with limited, hard-to-extend memory, degrades the running time performance, and restricts the design of network models. We address this challenge by developing a novel profile-guided memory optimization to efficiently and quickly allocate memory blocks during the propagation in DNNs. The optimization utilizes a simple and fast heuristic algorithm based on the two-dimensional rectangle packing problem. Experimenting with well-known neural network models, we confirm that our method not only reduces the memory consumption by up to $49.5\%$ but also accelerates training and inference by up to a factor of four thanks to the rapidity of the memory allocation and the ability to use larger mini-batch sizes.
Motivation & Objective
- To address the high memory consumption of deep neural networks (DNNs) during training and inference, especially on memory-constrained devices like GPUs and edge systems.
- To reduce peak memory usage in DNNs without altering model computation, enabling larger mini-batch sizes and improved GPU utilization.
- To develop a fast, profile-guided memory allocation technique that avoids the performance overhead of dynamic memory allocation in deep learning frameworks.
- To enable efficient memory management in both feedforward networks (e.g., CNNs) and recurrent networks (e.g., seq2seq) with variable-length inputs.
Proposed method
- The method profiles memory usage during a single forward pass of a DNN to capture the memory access pattern of 'hot' computation paths.
- It formulates the memory allocation problem as a two-dimensional rectangle packing problem to minimize peak memory usage.
- A simple, fast heuristic algorithm is developed to generate near-optimal memory block allocations efficiently.
- Memory addresses are precomputed and cached from the profile, enabling constant-time memory access in subsequent runs.
- The approach is integrated into the Chainer deep learning framework and is compatible with other frameworks.
- For variable-length sequences (e.g., in RNNs), the method re-computes allocations when necessary to avoid memory bloat from unused blocks.
Experimental results
Research questions
- RQ1Can profile-guided memory allocation significantly reduce peak memory usage in deep neural networks without runtime overhead?
- RQ2How effective is a fast heuristic-based approach for two-dimensional rectangle packing in minimizing memory consumption for DNNs?
- RQ3To what extent can memory reduction enable larger mini-batch sizes and improve GPU utilization in training?
- RQ4Does the method maintain or improve inference speed despite the profile computation cost?
- RQ5How does the method perform on models with variable-length inputs, such as RNNs?
Key findings
- The method reduces peak memory usage by up to 49.5% in ResNet-50 and Inception-ResNet, with reductions of 12.6% and 10.0% in GoogLeNet and ResNet-50 during inference.
- Training speed is accelerated by up to a factor of four due to faster memory allocation and higher GPU utilization from larger mini-batch sizes.
- Inference is accelerated by up to 23.8% in seq2seq models due to reduced memory allocation cost and better memory reuse.
- The heuristic algorithm runs quickly enough for practical use, with execution times under 1 second for most models.
- The method outperforms pool-based memory management in RNNs by avoiding memory pool fragmentation and reducing the need to free and reallocate memory.
- In 128 and 256 mini-batch sizes, training in the optimized version is faster than in the original Chainer due to reduced memory allocation overhead.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.