NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

xMem: A CPU-Based Approach for Accurate Estimation of GPU Memory in Deep Learning Training Workloads

Jiabo Shi, Dimitrios Pezaros, Yehia ElkhatibMiddleware 2025

TL;DR

This paper introduces xMem, a novel CPU-only framework for accurately predicting GPU memory usage during deep learning training. By analyzing CPU execution traces, xMem significantly reduces out-of-memory (OOM) errors and improves GPU memory conservation, crucial for managing scarce resources in shared clusters.

What Problem Does This Paper Address?

Deep learning (DL) models are increasingly complex and resource-intensive, leading to a global scarcity of GPUs. In shared DL training environments, accurately predicting how much GPU memory a job will require is fundamental for efficient scheduling and preventing costly Out-of-Memory (OOM) errors. Existing methods struggle to meet this challenge: static analysis often fails to capture dynamic runtime behavior, direct GPU analysis consumes valuable resources, and some techniques require intrusive code modifications. This leaves a critical gap for a method that is accurate, works a priori, and has zero overhead on the target GPU.

Methods

xMem tackles this problem with a CPU-based dynamic analysis framework. The core idea is to leverage the fact that the high-level logic of DL training scripts is largely hardware-agnostic. xMem works in three stages:

  1. Analyzer: This stage parses raw CPU profiling data (from tools like PyTorch Profiler) to extract and filter GPU-relevant memory events, attributing them to specific operations or components. It reconstructs memory block lifecycles (allocation to deallocation) and links them to operator contexts.
  2. Memory Orchestrator: This component refines the temporal characteristics of the CPU-based memory events to better reflect their expected lifecycles on a GPU. It adjusts timings for specific events like gradient persistence until optimizer.zero_grad() is called.
  3. Memory Simulator: This final stage replays the orchestrated memory sequence using a high-fidelity, two-level simulation of both the DL framework's allocator (e.g., PyTorch's CUDACachingAllocator) and the GPU's device allocator. This simulation accurately models complex behaviors like memory rounding, segment allocation, fragmentation, and caching to estimate peak GPU memory usage.

Datasets

The paper does not introduce new datasets. Instead, it uses a diverse set of 22 DL models (CNNs and Transformers) from various sources, detailed in Table 2 of the paper. These models are trained with a range of optimizers and batch sizes to simulate realistic workload variations. For specific experiments (RQ5), larger Transformer models were used, requiring access to more powerful GPUs.

Key Insights and Ideas

  • CPU Traces Hold the Key: The fundamental insight is that detailed CPU execution traces, when analyzed correctly, can accurately predict GPU memory behavior without needing to run on the GPU itself. This bypasses the need for expensive GPU resources for estimation.
  • Allocator Nuances Matter: The paper highlights that simply summing tensor sizes is insufficient. The behavior of memory allocators (both at the framework and device level), including their caching and fragmentation strategies, significantly impacts peak memory usage and must be simulated accurately.
  • Dynamic Behavior is Crucial: The placement of operations like optimizer.zero_grad() can drastically alter memory requirements, demonstrating the limitations of static analysis and the necessity of dynamic tracing.
  • Trade-off Between Accuracy and Reliability: While accuracy (low MRE) is important, the ability to reliably avoid OOM errors (low PEF) is paramount for practical scheduling. xMem demonstrates strong performance in both aspects.

Key Results

xMem significantly outperforms state-of-the-art (SOTA) methods:

  • Accuracy: Decreases Median Relative Error (MRE) by 91% compared to baselines. For CNN models, MRE is around 3%, and for Transformer models, it's around 4%.
  • Reliability: Reduces the Probability of Estimation Failure (PEF) by 75%, with a majority of tested configurations falling into the "Optimal" quadrant (low MRE and low PEF).
  • Memory Conservation: Achieves a 368% increase in Memory Conservation Potential (MCP) over current solutions, saving an average of 8.67 GB for CNNs and 7.07 GB for Transformers.
  • Runtime Overhead: xMem has an average runtime of 26 seconds, which is competitive with other CPU-based methods and considered practical for pre-submission estimation.
  • Scalability: xMem demonstrates strong accuracy and advantage over DNNMem even for larger Transformer models on high-end NVIDIA A100 GPUs.

Limitations and Future Work

  • Runtime Overhead: While acceptable for pre-submission checks, xMem's current runtime can be further optimized by incorporating advanced big data processing techniques and concurrent data pipelines.
  • Distributed Training: The current work focuses on single-GPU training. Future work will extend xMem to distributed training scenarios by analyzing per-layer/operator memory profiles and simulating distributed interactions.
  • Mixed-Precision Training: xMem can estimate memory for FP16 precision if profiling data is available. Future work aims to adapt it for new data types like FP8 by analyzing tensor dimensions and data type impacts.
  • Framework and Hardware Agnosticism: While designed for extensibility, future work will involve implementing modules for other DL frameworks and hardware devices to broaden its applicability.

Summary updated

BibTeX
@inproceedings{shi2025xmem,
  author = {Jiabo Shi and Dimitrios Pezaros and Yehia Elkhatib},
  title = {{xMem: A CPU-Based Approach for Accurate Estimation of GPU Memory in Deep Learning Training Workloads}},
  booktitle = {Middleware},
  year = {2025},
}
Figure