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

ms_deform_attn_forward_cuda" not implemented for 'BFloat16 #38

Open
ChinChyi opened this issue Aug 29, 2024 · 7 comments
Open

ms_deform_attn_forward_cuda" not implemented for 'BFloat16 #38

ChinChyi opened this issue Aug 29, 2024 · 7 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@ChinChyi
Copy link

Hello!

This is the problem when I use grounded_sam2_local_demo.py for image inference

@rentainhe
Copy link
Collaborator

Hi @ChinChyi

This is caused by Deformable Attention operator, which did not support BFloat16 inference, we will fix this bug later

@rentainhe
Copy link
Collaborator

rentainhe commented Aug 30, 2024

Hi @ChinChyi

Have you changed any code in your local env, we have fix this bug in our original implementation here:

torch.autocast(device_type="cuda", dtype=torch.bfloat16).__enter__()

By removing

# FIXME: figure how does this influence the G-DINO model
torch.autocast(device_type="cuda", dtype=torch.bfloat16).__enter__()

if torch.cuda.get_device_properties(0).major >= 8:
    # turn on tfloat32 for Ampere GPUs (https://pytorch.org/docs/stable/notes/cuda.html#tensorfloat-32-tf32-on-ampere-devices)
    torch.backends.cuda.matmul.allow_tf32 = True
    torch.backends.cudnn.allow_tf32 = True

After running grounding dino

@Khlann
Copy link

Khlann commented Sep 2, 2024

So, what is the solution?I have also encounter this problem.Thank you very much!

@Khlann
Copy link

Khlann commented Sep 2, 2024

This error happened when I called self.sam2_predictor.predicttwice

@rentainhe
Copy link
Collaborator

This error happened when I called self.sam2_predictor.predicttwice

Would you like to share your code with us which may be more convenient for us to debug this issue.

@ChinChyi
Copy link
Author

ChinChyi commented Sep 3, 2024

Hi @ChinChyi

Have you changed any code in your local env, we have fix this bug in our original implementation here:

torch.autocast(device_type="cuda", dtype=torch.bfloat16).__enter__()

By removing

# FIXME: figure how does this influence the G-DINO model
torch.autocast(device_type="cuda", dtype=torch.bfloat16).__enter__()

if torch.cuda.get_device_properties(0).major >= 8:
    # turn on tfloat32 for Ampere GPUs (https://pytorch.org/docs/stable/notes/cuda.html#tensorfloat-32-tf32-on-ampere-devices)
    torch.backends.cuda.matmul.allow_tf32 = True
    torch.backends.cudnn.allow_tf32 = True

After running grounding dino

Thanks

@rentainhe rentainhe added the bug Something isn't working label Sep 3, 2024
@MagdalenaKotynia
Copy link

@ChinChyi changing bloat16 to float16 (torch.autocast(device_type="cuda", dtype=torch.bfloat16).__enter__() to torch.autocast(device_type="cuda", dtype=torch.float16).__enter__() ) helped for me.

@rentainhe rentainhe added the documentation Improvements or additions to documentation label Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants