DINOv2 (fastforks)
DINOv2 (Oquab et al. 2023, Meta): self-supervised ViT backbones; patch + cls token features at any size; -reg = with 4 register tokens.
This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/facebookresearch/dinov2 at 7764ea0.
Task: features. Tier: stable. Outputs: last_hidden_state, pooler_output, hidden_states. Backends: portable, kernels.
Input: one RGB image. Output: dense patch features and a pooled image feature.
Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
dinov2-vitb14@1 |
dinov2_vitb14_pretrain.pth | 0b8b82f85de9 |
Apache-2.0 | yes |
dinov2-vitb14-reg@1 |
dinov2_vitb14_reg4_pretrain.pth | 73182a088cf9 |
Apache-2.0 | yes |
dinov2-vitg14@1 |
dinov2_vitg14_pretrain.pth | baf8467e50af |
Apache-2.0 | yes |
dinov2-vitg14-reg@1 |
dinov2_vitg14_reg4_pretrain.pth | 746ecb8c6301 |
Apache-2.0 | yes |
dinov2-vitl14@1 |
dinov2_vitl14_pretrain.pth | d5383ea8f487 |
Apache-2.0 | yes |
dinov2-vitl14-reg@1 |
dinov2_vitl14_reg4_pretrain.pth | 36e4deffbaef |
Apache-2.0 | yes |
dinov2-vits14@1 |
dinov2_vits14_pretrain.pth | b938bf1bc15c |
Apache-2.0 | yes |
dinov2-vits14-reg@1 |
dinov2_vits14_reg4_pretrain.pth | f433177089a6 |
Apache-2.0 | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: LICENSE.
Training data: LVD-142M: 142M images retrieved from web crawls by similarity to curated datasets (ImageNet-22k/1k train, Google Landmarks, fine-grained sets), self-supervised (no labels), per the paper; not released.
Licence evidence: https://github.com/facebookresearch/dinov2/blob/7764ea0/README.md (License section: code and model weights under Apache 2.0)
Input size
any H x W >= 1, resized or padded inside the model
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): dinov2-vitb14 3000x4000 (1.4 GiB peak allocated, 2.2 reserved); dinov2-vitb14-reg 3000x4000 (1.4 GiB peak allocated, 2.2 reserved); dinov2-vitg14 3000x4000 (4.8 GiB peak allocated, 5.9 reserved); dinov2-vitg14-reg 3000x4000 (4.8 GiB peak allocated, 5.9 reserved); dinov2-vitl14 3000x4000 (2.2 GiB peak allocated, 3.1 reserved); dinov2-vitl14-reg 3000x4000 (2.2 GiB peak allocated, 3.1 reserved); dinov2-vits14 3000x4000 (0.8 GiB peak allocated, 1.2 reserved); dinov2-vits14-reg 3000x4000 (0.8 GiB peak allocated, 1.2 reserved)
Speed and memory
Features, synthetic, 224x224
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|
dinov2-vitb14 |
6.90 | 4.50 | 2.92 | 1.50 | 3.0x | 1.9x | 530 / 548 | 205 / 226 | 208 / 228 |
dinov2-vitb14-reg |
7.00 | 4.30 | 2.94 | 1.52 | 2.8x | 1.9x | 530 / 548 | 207 / 226 | 208 / 228 |
dinov2-vitg14 |
86.4 | 33.9 | 18.9 | 12.8 | 2.7x | 1.5x | 6542 / 6548 | 2216 / 2230 | 2222 / 2250 |
dinov2-vitg14-reg |
86.6 | 34.2 | 18.7 | 12.7 | 2.7x | 1.5x | 6542 / 6568 | 2217 / 2228 | 2222 / 2250 |
dinov2-vitl14 |
22.8 | 9.80 | 6.13 | 4.62 | 2.1x | 1.3x | 1777 / 1784 | 622 / 644 | 627 / 648 |
dinov2-vitl14-reg |
22.5 | 10.7 | 6.38 | 4.60 | 2.3x | 1.4x | 1777 / 1786 | 624 / 646 | 627 / 648 |
dinov2-vits14 |
3.30 | 4.40 | 2.95 | 0.827 | 4.0x | 3.6x | 160 / 166 | 79 / 98 | 80 / 122 |
dinov2-vits14-reg |
4.11 | 5.59 | 2.98 | 0.832 | 4.9x | 3.6x | 160 / 168 | 80 / 98 | 80 / 102 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
dinov2-vitb14 |
1.51 | 0.27 | 0.19 | 0.01 | 0.20 | 0.19 |
dinov2-vitb14-reg |
1.71 | 0.59 | 0.21 | 0.04 | 0.04 | 0.20 |
dinov2-vitg14 |
19.29 | 4.37 | 2.22 | 0.05 | 0.10 | 0.16 |
dinov2-vitg14-reg |
14.67 | 4.32 | 15.39 | 0.09 | 0.03 | 0.15 |
dinov2-vitl14 |
7.06 | 2.30 | 2.31 | 0.01 | 0.09 | 0.12 |
dinov2-vitl14-reg |
4.60 | 2.08 | 2.11 | 0.07 | 0.09 | 0.12 |
dinov2-vits14 |
0.41 | 0.07 | 0.07 | 0.17 | 0.12 | 0.15 |
dinov2-vits14-reg |
1.32 | 0.21 | 0.08 | 0.11 | 0.13 | 0.17 |
torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT (fp16 unless shown) | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|---|---|---|---|---|---|---|---|---|---|---|---|
dinov2-vitb14 |
224x224 | 2.92 ms | 2.20 ms | 1.30 ms | 1.50 ms | 9.52 s | 25.2 s | 205 / 226 | 240 / 266 | 208 / 228 | 367 / 384 |
dinov2-vitb14-reg |
224x224 | 2.94 ms | 2.30 ms | 1.33 ms | 1.52 ms | 6.12 s | 29.2 s | 207 / 226 | 240 / 246 | 208 / 228 | 399 / 402 |
dinov2-vitg14 |
224x224 | 18.9 ms | 18.3 ms | 12.0 ms | 12.8 ms | 19.0 s | 46.5 s | 2216 / 2230 | 2267 / 2290 | 2222 / 2250 | 4392 / 4410 |
dinov2-vitg14-reg |
224x224 | 18.7 ms | 18.3 ms | 12.0 ms | 12.7 ms | 15.4 s | 56.9 s | 2217 / 2228 | 2267 / 2290 | 2222 / 2250 | 4400 / 4418 |
dinov2-vitl14 |
224x224 | 6.13 ms | 6.03 ms | 4.25 ms | 4.62 ms | 13.2 s | 33.5 s | 622 / 644 | 661 / 666 | 627 / 648 | 1235 / 1262 |
dinov2-vitl14-reg |
224x224 | 6.38 ms | 6.17 ms | 4.27 ms | 4.60 ms | 9.55 s | 42.0 s | 624 / 646 | 661 / 666 | 627 / 648 | 1237 / 1242 |
dinov2-vits14 |
224x224 | 2.95 ms | 2.02 ms | 0.601 ms | 0.827 ms | 9.99 s | 22.9 s | 79 / 98 | 111 / 140 | 80 / 122 | 141 / 160 |
dinov2-vits14-reg |
224x224 | 2.98 ms | 2.19 ms | 0.614 ms | 0.832 ms | 6.11 s | 32.1 s | 80 / 98 | 111 / 118 | 80 / 102 | 145 / 164 |
Fixed-size speed and peak memory, all models
| model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
|---|---|---|---|---|---|
dinov2-vitb14 |
portable | 10.3 ms / 231 / 242 | 39.8 ms / 295 / 342 | 137.6 ms / 417 / 442 | 3232.4 ms (n=3) / 1460 / 1562 |
dinov2-vitb14 |
kernels | 7.5 ms / 243 / 262 | 28.0 ms / 324 / 362 | 94.7 ms / 480 / 542 | 2147.8 ms (n=3) / 1821 / 2002 |
dinov2-vitb14-reg |
portable | 10.1 ms / 238 / 254 | 39.9 ms / 303 / 368 | 140.2 ms / 423 / 544 | 3244.0 ms (n=3) / 1467 / 2244 |
dinov2-vitb14-reg |
kernels | 7.6 ms / 254 / 374 | 28.1 ms / 337 / 452 | 94.7 ms / 492 / 704 | 2147.6 ms (n=3) / 1833 / 2404 |
dinov2-vitg14 |
portable | 101.5 ms / 2273 / 2304 | 375.9 ms / 2410 / 2464 | 1169.8 ms / 2673 / 2764 | 23035.0 ms (n=3) / 4929 / 5404 |
dinov2-vitg14 |
kernels | 69.7 ms / 2296 / 2322 | 257.4 ms / 2469 / 2522 | 797.8 ms / 2801 / 2924 | 15248.1 ms (n=3) / 5650 / 6264 |
dinov2-vitg14-reg |
portable | 101.8 ms / 2294 / 2454 | 377.1 ms / 2432 / 2656 | 1184.7 ms / 2694 / 2984 | 23131.1 ms (n=3) / 4951 / 6020 |
dinov2-vitg14-reg |
kernels | 70.3 ms / 2298 / 2634 | 257.6 ms / 2472 / 2864 | 802.9 ms / 2803 / 3352 | 15244.2 ms (n=3) / 5654 / 6720 |
dinov2-vitl14 |
portable | 29.8 ms / 656 / 682 | 118.1 ms / 736 / 782 | 395.5 ms / 889 / 902 | 8770.0 ms (n=3) / 2205 / 2482 |
dinov2-vitl14 |
kernels | 19.6 ms / 671 / 702 | 77.1 ms / 775 / 802 | 252.1 ms / 974 / 1042 | 5331.0 ms (n=3) / 2686 / 2862 |
dinov2-vitl14-reg |
portable | 30.1 ms / 656 / 682 | 118.2 ms / 736 / 782 | 396.1 ms / 889 / 982 | 8778.1 ms (n=3) / 2205 / 2622 |
dinov2-vitl14-reg |
kernels | 19.6 ms / 671 / 702 | 77.1 ms / 775 / 802 | 252.5 ms / 974 / 1042 | 5326.8 ms (n=3) / 2686 / 2982 |
dinov2-vits14 |
portable | 4.3 ms / 95 / 116 | 16.8 ms / 133 / 176 | 61.4 ms / 207 / 256 | 1574.5 ms / 843 / 976 |
dinov2-vits14 |
kernels | 3.3 ms / 100 / 116 | 12.0 ms / 148 / 176 | 39.0 ms / 239 / 276 | 957.1 ms / 1023 / 1116 |
dinov2-vits14-reg |
portable | 4.3 ms / 96 / 108 | 16.9 ms / 135 / 164 | 61.3 ms / 210 / 248 | 1582.1 ms / 846 / 1240 |
dinov2-vits14-reg |
kernels | 3.3 ms / 106 / 148 | 12.0 ms / 153 / 176 | 39.0 ms / 244 / 308 | 960.9 ms / 1029 / 1344 |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
Accuracy
On public datasets
Two disjoint seeded subsets of the val folders; each image shorter side 256 (bicubic), centre crop 224, the CLS / pooled feature; cosine kNN, vote weighted by similarity. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
dinov2-vits14 |
ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 59.20 | 59.22 | 59.26 | 59.22 | 59.16 | |
dinov2-vits14-reg |
ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 59.98 | 60.00 | 59.96 | 59.98 | 59.96 | |
dinov2-vitb14 |
ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 67.80 | 67.76 | 67.74 | 67.80 | 67.78 | |
dinov2-vitb14-reg |
ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 69.14 | 69.18 | 69.14 | 69.14 | 69.18 | |
dinov2-vitl14 |
ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 72.12 | 72.16 | 72.18 | 72.12 | 72.14 | |
dinov2-vitl14-reg |
ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 73.08 | 73.08 | 73.06 | 73.08 | 73.08 | |
dinov2-vitg14 |
ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 70.64 | 70.66 | 70.64 | 70.64 | 70.68 | |
dinov2-vitg14-reg |
ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 72.60 | 72.58 | 72.60 | 72.60 | 72.64 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7c91993, 2026-10-31; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.0001 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 2.5 % and p99 <= 12 % of the reference's median |value| (absolute error of the output last_hidden_state).
Limitations
- On CUDA, stream=True stages the transformer blocks from pinned host RAM. Streamed inference uses eager execution and requires enough host RAM for the blocks.
- With all hidden states requested at 756 ร 1008, ViT-L with registers reduced CUDA peak allocation from 1,416 to 1,096 MiB portable and from 1,419 to 1,108 MiB kernels. The final features and every requested state matched bitwise.
Usage
from fastforks import features
model = features.load("dinov2-vitb14") # mode="auto": the preferred backend from recorded measurements
result = model("photo.jpg", size=518)
result.last_hidden_state # tokens [N, C], as Hugging Face's output
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: dinov2-vitb14, dinov2-vitb14-reg, dinov2-vitg14, dinov2-vitg14-reg, dinov2-vitl14, dinov2-vitl14-reg, dinov2-vits14, dinov2-vits14-reg.
Kernels backend
features.load("dinov2-vitb14", mode="kernels") runs our CUDA kernels (fastbb, dpt_fused). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.