ByteDance-Seed / ByteDance-Seed/Bagel
CUDA out of memory
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 545
- PR merge metrics
- No merged PRs in 30d
Description
**Title:** CUDA Out of Memory During BAGEL Training on A100 80GB (384x512 images, 500 samples)
**Issue Description:**
I’m experiencing a **CUDA Out of Memory error** when running the BAGEL training script using a single A100 80GB GPU.
---
### 🖥️ **Environment**
* **GPU:** A100 80GB (single)
* **CUDA Memory Error:** Yes
* **Image Size:** 384x512
* **Number of Images:** 500 (2 images per row per sample)
* **num\_shard:** 1
* **Script Used:** `train/pretrain_unified_navit.py`
---
### 🛠️ **Shell Script**
```bash
#!/bin/bash
cd /home/bilal/sahal/BAGEL
export PYTHONPATH=/home/bilal/sahal/BAGEL:$PYTHONPATH
torchrun \
--nnodes=1 \
--node_rank=0 \
--nproc_per_node=1 \
train/pretrain_unified_navit.py \
--dataset_config_file ./data/configs/example.yaml \
--model_path /home/bilal/sahal/BAGEL/models/BAGEL-7B-MoT \
--layer_module Qwen2MoTDecoderLayer \
--max_latent_size 64 \
--finetune_from_hf True \
--auto_resume False \
--resume-model-only False \
--finetune-from-ema True \
--log_every 1 \
--lr 2e-5 \
--num_worker 1 \
--expected_num_tokens 4096 \
--max_num_tokens 5120 \
--max_num_tokens_per_sample 4096 \
--cpu_offload True
```
---
### 🧠 **What I’ve Tried**
* Ensured `--cpu_offload` is enabled
* Reduced `max_num_tokens` and `max_num_tokens_per_sample` to 4096
* Limited number of workers to 1
---
### ❓**Questions / Help Needed**
* Given the data (2 images per row, 500 samples), are the `max_num_tokens` settings too high for a 7B model on a single A100?
* Should I further reduce `max_latent_size` or `expected_num_tokens`?
* Is the model path (`BAGEL-7B-MoT`) too heavy without gradient checkpointing?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with train/pretrain_unified_navit.py and reproduce the provided torchrun command on the single A100 configuration. Trace which settings contribute to memory use, including max_latent_size, expected_num_tokens, max_num_tokens, and cpu_offload. Done means the reported training configuration starts without a CUDA out-of-memory error, with the working settings documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100