dinov2
dinov2 copied to clipboard
CUDA check before importing xFormers.
I don't know how useful this might be, but in some cases attempts to run DINOv2 on CPU would fail because the xformers requirement could be satisfied, but the model itself is not on CUDA.
This adds a few lines to attention and block to checks if torch was compiled with CUDA before attempting to import xFormers. Regardless of whether CUDA is available or not, torch needs to be compiled with CUDA in order for tensors to be mappable to device, so if it's not, attempting to import xFormers might succeed if the user has xFormers installed in their environment.
Related issue: #3 .