Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs / SAM ] Reflect correct changes to run inference without OOM #27268

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

younesbelkada
Copy link
Contributor

@younesbelkada younesbelkada commented Nov 3, 2023

What does this PR do?

Fixes #27266

One needs to always wrap the model forward pass to avoid OOM issues for SAM forward pass. In the orignal modeling code they force-use torch.no_grad() context manager in the forward pass: https://github.com/facebookresearch/segment-anything/blob/main/segment_anything/modeling/sam.py#L53 - but we avoid that since we also support SAM fine-tuning.

Check out my comment here for more details: #27266 (comment)

cc @amyeroberts

@younesbelkada younesbelkada changed the title [Docs / ] [Docs / SAM ] Reflect correct changes to run inference with OOM Nov 3, 2023
@younesbelkada younesbelkada changed the title [Docs / SAM ] Reflect correct changes to run inference with OOM [Docs / SAM ] Reflect correct changes to run inference without OOM Nov 3, 2023
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating!

@younesbelkada younesbelkada merged commit ad8ff96 into main Nov 3, 2023
3 checks passed
@younesbelkada younesbelkada deleted the younesbelkada-patch-1 branch November 3, 2023 14:23
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

EduardoPach pushed a commit to EduardoPach/transformers that referenced this pull request Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segment anything: CUDA out of memory
3 participants