Skip to content

Optimize VRAM Allocation on 16GB GPUs to Prevent CUDA Out-of-Memory Errors #5

Description

@purvanshjoshi

Technical Overview

Fine-tuning Whisper-Medium with standard sequence lengths on 16GB VRAM GPUs (like Tesla T4) regularly triggers Out-of-Memory (OOM) failures due to the size of the attention map allocations. Training requires aggressive memory optimizations to maintain a stable effective batch size.

Affected Modules

  • File: src/train.py (Line 110-140)
  • System: VRAM allocations on 16GB GPUs.

Acceptance Criteria

  1. Continuous Execution: The training script completes the full 4000 steps without hitting CUDA OOM constraints.
  2. Stable Batch Representation: Maintains an effective batch size of 16 using gradient accumulation without exceeding 13GB VRAM allocation.
  3. Optimized Throughput: Minimizes VRAM allocation while maximizing samples processed per second.

Proposed Implementation Approach

  1. Enable gradient_checkpointing=True to reconstruct the backward pass activations dynamically, saving substantial forward pass memory.
  2. Pin training parameters to fp16=True mixed precision.
  3. Enforce 8-bit quantization mapping in combination with LoRA parameters target modules (q_proj, v_proj).
  4. Set parameter configurations: per_device_train_batch_size=4 paired with gradient_accumulation_steps=4.

Severity & Priority

  • Severity: High (Limits model scaling and training stability)
  • Priority: P1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions