dinov2 icon indicating copy to clipboard operation
dinov2 copied to clipboard

CUDA check before importing xFormers.

Open alihassanijr opened this issue 1 year ago • 0 comments

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 .

alihassanijr avatar Apr 18 '23 20:04 alihassanijr