facebookresearch / facebookresearch/segment-anything

Strange CUDA: OOM (Out of Memory) Issue

Open
#779 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
54.9k
Forks
6.4k
PR merge metrics
No merged PRs in 30d

Description

Hi, So I'm currently trying to train SAM with different configurations.
So I've modified the depth and patch size in the codes, I'm facing one strange issue.
Below is the vit-h (ignore attention indexes...)
![image](https://github.com/user-attachments/assets/7eaff96d-65d7-410e-8413-4f2fd6d09b9a)
and Below is the vit-b:
![image](https://github.com/user-attachments/assets/a0c75287-e80b-46ac-b123-45ea974a7f5d)

This is the patch size (kept same for both)
![image](https://github.com/user-attachments/assets/d75e7776-3555-4ea1-801c-4db4060ba3e4)

To my surprise, the model with vit-h is training fine:
![image](https://github.com/user-attachments/assets/64b8834b-af61-4a94-8245-53e29e57bf77)
But the model with vit-b keeps giving me OOM Issue:
![image](https://github.com/user-attachments/assets/fe03decf-dbf4-4776-aac5-6f8cb2c7224e)

I'm confused, how and why! Vit-B is lighter than Vit-H, if Vit-H is getting trained, then Vit-B should train as well.

BTW, I'm also training the Image encoder in both cases.

Contributor guide

Open the contributing guide

Research direction

No source file, test, command, or complete configuration is named; start by reproducing the reported CUDA OOM with the modified ViT-B and ViT-H depth and patch-size settings. Collect the exact model, batch, image, GPU, and memory details, then determine whether the discrepancy is reproducible and document a confirmed cause or minimal reproduction.

Written by the indexing model from the issue text.

Assessment

Domain
machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.