Skip to content

CUDA Out-of-Memory on single L20 — How to train with 2 GPUs? #62

@pzwstudy

Description

@pzwstudy

Hi, thanks for your great work!
I’m trying to finetune the model using LoRA, but I keep running into CUDA OOM even on a single L20 (48GB) GPU.

❗ Error message
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 130.00 MiB.
GPU 0 has a total capacity of 44.53 GiB of which 85.94 MiB is free.
Including non-PyTorch memory, this process has 44.44 GiB memory in use.
Of the allocated memory 44.05 GiB is allocated by PyTorch, ...
If reserved but unallocated memory is large try setting
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.

💻 Hardware

2 × NVIDIA L20 (48GB)

CUDA 12.x

PyTorch version: (same as your install guide)

accelerate version: latest

📦 Command I used
accelerate launch train.py --config ./train_configs/train_lora.yaml

❓ My question

Since one L20 is not enough, I would like to run training across two GPUs.

Could you please provide guidance on:

How to configure accelerate to enable 2-GPU training for this project?

Are there additional configs (e.g., device_map, distributed_type, gradient checkpointing, batch size limits) that I should modify for multi-GPU LoRA finetuning?

Any known memory optimizations for Qwen2.5-Image LoRA training?

🙏 Thanks!

Any help would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions