-
Notifications
You must be signed in to change notification settings - Fork 678
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
High resolution image result with NaN features #33
Comments
The linked image is 2144x1319. Maybe:
Edit: Nevermind, you resize the image to a shape multiple of the patch size (14). Plus, the model would have cropped the image. |
You could make a debug function that checks the current values of the embedding vector for NaN entries, then insert that function btw various layers of the model to see in which layer the NaN start to appear, it might help us help you. |
After debugging the issue further, I found that the problematic function causing NaN values in the features is memory_efficient_attention, which is part of the xFormers library used by Dinov2. Here is the relevant code snippet from Dinov2's attention.py file: dinov2/dinov2/layers/attention.py Lines 65 to 85 in f896929
The output tensor is full of NaN during the forward pass of the first block. |
Shows how to replace memory_efficient_attention with normal attention, could fix your issue. |
Regrettably, I need this function for the purpose of saving memory since the image necessitates nearly 100 gigabytes of RAM, which surpasses my requirements. |
I was somehow able to find an image that work without |
It seems that I did not make enough research before creating this issue: [0.0.18] memory_efficient_attention NaNs when seqlen>32768 #719 I'll try upgrading and determine if this will resolve the problem. |
It resolved the problem, it works with the version |
Hello,
I'm having an issue with Dinov2 while trying to use it with high-resolution images like the one available at this link. The problem is that the features returned by the model contain NaN values. This issue occurs with all four available models and is consistently present for images around the same size.
I would like to know if you have any ideas about what could be causing this problem. Here's an minimal example:
The text was updated successfully, but these errors were encountered: