Skip to content

Can't reproduce 10B parameters GPT-2 training, CUDA out of memory #477

Closed

Description

@ollmer

Hi!
I'm trying to run 10B params model training on a 32 V100 GPUs, following the tutorial https://www.deepspeed.ai/tutorials/zero/#training-a-10b-parameter-gpt-2-model
But i consistently get CUDA out of memory even when i've reduced model size to 6B params and batch size to 1.
Here are my configs:

       --model-parallel-size 1 \
       --num-layers 40 \
       --hidden-size 3072 \
       --num-attention-heads 24 \
       --batch-size 1 \
       --seq-length 1024 \
       --max-position-embeddings 2048 \

deepspeed config

{
  "train_batch_size": 32,
  "gradient_accumulation_steps": 1,
  "steps_per_print": 100,  "gradient_clipping": 1.0,
  "wall_clock_breakdown": true,  
  "fp16": {    "enabled": true,    "loss_scale": 0,
    "loss_scale_window": 1000,
    "hysteresis": 2,
    "min_loss_scale": 0.0000001
  },
  "zero_optimization": {
    "stage":2,
    "contiguous_gradients": true,
    "overlap_comm": true,
    "reduce_scatter": true,
    "reduce_bucket_size": 50000000,
    "allgather_bucket_size": 500000000
  }
}

Hardware setup is 2 DGX-2.
Do i need to turn on activations checkpointing to make it work? Or is there some other caveats?

Activity

  1. changed the title [-]Can't reproduce 10B parameters GPT-2 model training[/-] [+]Can't reproduce 10B parameters GPT-2 model training, CUDO out of memory[/+] on Oct 20, 2020
  2. changed the title [-]Can't reproduce 10B parameters GPT-2 model training, CUDO out of memory[/-] [+]Can't reproduce 10B parameters GPT-2 training, CUDO out of memory[/+] on Oct 20, 2020
  3. changed the title [-]Can't reproduce 10B parameters GPT-2 training, CUDO out of memory[/-] [+]Can't reproduce 10B parameters GPT-2 training, CUDA out of memory[/+] on Oct 20, 2020
  4. tjruwase commented on Oct 20, 2020

    @tjruwase
    Contributor

    @ollmer Can you clarify how GPU count and RAM size?

  5. ollmer commented on Oct 21, 2020

    @ollmer
    Author

    It runs on 32 V100 GPUs with 32Gb RAM each.

  6. ollmer commented on Oct 21, 2020

    @ollmer
    Author

    Also worth mention that It's fp16 mode. So i expect optimizer state to require 120Gb of ram, which should be 4 Gb per GPU in zero stage 2 mode.

  7. tjruwase commented on Oct 21, 2020

    @tjruwase
    Contributor

    Can you please share your training log?

  8. tjruwase commented on Oct 23, 2020

    @tjruwase
    Contributor

    @ollmer Just wanted to follow up whether you could share your training log? Thanks.

  9. ollmer commented on Oct 26, 2020

    @ollmer
    Author

    Sorry for delay. Here it is.
    failed10b_train_2_cuda_oom.log

  10. tjruwase commented on Oct 26, 2020

    @tjruwase
    Contributor

    Thanks for sharing the log. Can you try the following?

    1. Disable overlap_comm
    2. Reduce allgather_bucket_size to 1e8 or 5e7
  11. ollmer commented on Oct 26, 2020

    @ollmer
    Author

    I've tried it. Still got OOM.
    failed10b_train_3_cuda_oom.log

  12. tjruwase commented on Oct 26, 2020

    @tjruwase
    Contributor

    Thanks for sharing the log. I will try to repro this issue on my side.

  13. samyam commented on Oct 30, 2020

    @samyam
    Contributor

    @ollmer the OOM you are seeing should be resolved by enabling activation_checkpointing in addition to enabling zero_offload.

  14. ollmer commented on Oct 30, 2020

    @ollmer
    Author

    Hi @samyam!
    I'm talking about zero-2 mode, not about offload to CPU. And that was exactly my question about checkpointing from the original post:

    Do i need to turn on activations checkpointing to make it work? Or is there some other caveats?

    I wonder what is the maximum size of the model that could be trained without checkpointing? Because it slows thing down a lot. The tutorial looks like it assumes that 10B model could be trained without checkpointing.

  15. samyam commented on Oct 30, 2020

    @samyam
    Contributor

    @ollmer I see now. Yes, on 32 V100 GPUs ZeRO-2 should work without offload, and yes you need to turn on activation checkpointing. Model size beyond a few billion parameters all need activation checkpointing to be enabled in addition to ZeRO-2 or ZeRO-Offload, which ever you might be using. We will clarify that on the tutorial.

    The activation checkpointing will have about 33% overhead, often lower. Are you seeing a much larger overhead?

  16. ollmer commented on Oct 30, 2020

    @ollmer
    Author

    Thanks for clarification! I'll measure the exact slowdown numbers and post it here later.

  17. added a commit that references this issue on Apr 11, 2023
  18. self-assigned this
    on Sep 8, 2023
  19. xiexbing commented on Sep 14, 2023

    @xiexbing
    Contributor

    the software issue has been solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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