Models · Semantic segmentation

DINOv2 linear

Meta's DINOv2 features with a linear layer on top for ADE20K scene segmentation.

stable Fork of facebookresearch/dinov2@7764ea0 · backends: portable, kernels

Checkpoint

Paper 2023 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 11.8 ms 1024x2048, fp16
vs the faster original 2.1× original fp16: 24.7 ms
Peak memory 645 MiB original: 1,694 MiB
Accuracy vs original fp32 −0.02 kernels mIoU %, ADE20K val (42.39 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import segmentation

model = segmentation.load("dinov2-s-linear-ade20k")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.logits
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench dinov2-s-linear-ade20k

Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.

Speed and memory

Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32 55.80.44×1,653 MiB/2,010 MiB––
Original fp16torch.autocast(fp16) around the forwardfp16 24.7–1,694 MiB/2,046 MiB––
Portable fp32fp32not measured ––––
Portablefp16 18.31.3×642 MiB/696 MiB0.10.09
Kernelsfp16 11.82.1×645 MiB/676 MiB1.00.06
Portable + torch.compile 20.71.2×1,331 MiB/1,376 MiB11 (build)–
TensorRT fp16fp16 40.30.61×1,794 MiBenginenot comparable36 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-12. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.

Other devices

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp32264 2,830 MiB processmatches1024x2048
Portablefp16195 1,532 MiB processmatches1024x2048
Portablefp32224 2,529 MiB processmatches1024x2048
Kernelsfp16not implemented–1024x2048
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1621.6 615 MiB/656 MiB–1024x2048
Kernelsfp1616.6 618 MiB/656 MiB–1024x2048
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp169.32 615 MiB/656 MiB–1024x2048
Kernelsfp166.60 618 MiB/656 MiB–1024x2048
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1616.6 615 MiB/656 MiB–1024x2048
Kernelsfp1613.1 618 MiB/656 MiB–1024x2048
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1610.1 615 MiB/656 MiB–1024x2048
Kernelsfp167.64 618 MiB/656 MiB–1024x2048
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp165.11 639 MiB/676 MiB–1024x2048
Kernelsfp163.90 642 MiB/676 MiB–1024x2048

CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.

Licence and weights

Commercial use allowed

Code
Apache-2.0
Weights
Apache-2.0 source
Training data

Our reading of the licences, not legal advice.

Weights

dinov2-s-linear-ade20k.backbone.pth 88.3 MB· hosted on Meta (fbaipublicfiles)
dinov2-s-linear-ade20k.head.pth 720 KB· hosted on Meta (fbaipublicfiles)

fastforks downloads and checks these files on first use (fastforks download dinov2-s-linear-ade20k).

Accuracy

The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.

ADE20K val

every 4th image, mIoU / aAcc %

RundtypemIoU % ↑aAcc % ↑Δ mIoU % vs fp32 originalimagesms / image
Original fp32fp3242.3979.40 reference 500 33.4
Original fp16fp1642.3879.40 −0.01 500 14.3
Portable fp32fp3242.3979.40 ±0.00 500 29.2
Portablefp1642.3879.39 −0.01 500 10.0
Kernelsfp1642.3779.39 −0.02 500 8.24

Each image at its own size, argmax of the logits. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Closeness to the original

Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 and p99 <= 0.25 (absolute error of the output logits).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 not recorded
GPU default dtypes, mean |diff|≤ 0.05 0.00655
GPU default dtypes, p99 |diff|≤ 0.25 0.02391

Recorded for dinov2-s-linear-ade20k on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-12, with these kernels: dpt_fusedfastbbseg_up

Details

DINOv2 (Oquab et al. 2023) linear probe: the frozen self-supervised ViT-S/B/L/14, a batch norm and a 1x1 classifier on the last block's patch tokens; the authors' ADE20K `linear` heads, sliding-window inference.

Input / output
Input: one RGB image. Output: per-pixel class labels (logits with logits=True).
Input size
any H x W >= 1, resized or padded inside the model; tested up to 3000x4000 (7,356 MiB allocated)
Outputs
logits
Checkpoint
arch="vits"
CUDA kernels
  • fastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbones
  • seg_upfused resize and argmax of segmentation scores
  • dpt_fusedfused fp16 matrix multiplies and convolutions for DINOv2 backbones and DPT depth heads
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

Meta's DINOv2 features with a linear layer on top for ADE20K scene segmentation.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
dinov2-s-linear-ade20ksynthetic (1024x2048)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
55.8
24.7
18.3
11.8
20.7
40.3
1653 / 2010
1694 / 2046
642 / 696
645 / 676
1331 / 1376
3084 / 3130
dinov2-b-linear-ade20ksynthetic (1024x2048)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
115
40.1
33.3
20.1
35.8
49.5
1899 / 2224
2063 / 2426
765 / 884
771 / 884
1455 / 1504
3367 / 3424
dinov2-l-linear-ade20ksynthetic (1024x2048)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
332
95.7
83.9
52.8
84.5
82.1
2730 / 3124
3308 / 3726
1181 / 1244
1189 / 1244
1870 / 1904
4257 / 4318
Details
  • Original code: https://github.com/facebookresearch/dinov2 at 7764ea0f912e
  • Code licence: Apache-2.0 (permissive); files:
  • Weights licence: Apache-2.0
  • Licence evidence: https://github.com/facebookresearch/dinov2/blob/7764ea0f912e53c92e82eb78a2a1631e92725fc8/README.md#L660
  • Training data: LVD-142M (DINOv2's curated web-image set, not released), ADE20K (SceneParsing, 150 classes)
  • Kernel libraries: fastbb, seg_up, dpt_fused
  • Variants: dinov2-s-linear-ade20k, dinov2-b-linear-ade20k, dinov2-l-linear-ade20k
  • Outputs: logits; label_set: ade20k-150
  • Input size: any H x W >= 1, resized or padded inside the model
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): dinov2-s-linear-ade20k 3000x4000 (7.2 GiB peak allocated, 7.9 reserved); dinov2-b-linear-ade20k 3000x4000 (7.3 GiB peak allocated, 8.1 reserved); dinov2-l-linear-ade20k 3000x4000 (7.7 GiB peak allocated, 8.5 reserved)
  • dinov2-s-linear-ade20k 1024x2048, first call: portable + torch.compile 11 s (cold Inductor cache), TensorRT fp16 36 s (ONNX + engine).
  • dinov2-b-linear-ade20k 1024x2048, first call: portable + torch.compile 11 s (cold Inductor cache), TensorRT fp16 41 s (ONNX + engine).
  • dinov2-l-linear-ade20k 1024x2048, first call: portable + torch.compile 16 s (cold Inductor cache), TensorRT fp16 44 s (ONNX + engine).
  • dinov2-s-linear-ade20k original 1024x2048: torch.autocast(fp16) around the forward
  • dinov2-b-linear-ade20k original 1024x2048: torch.autocast(fp16) around the forward
  • dinov2-l-linear-ade20k original 1024x2048: torch.autocast(fp16) around the forward
  • dinov2-s-linear-ade20k load / first call: original 4.02 s / 0.303 s (512x512), portable 0.12 s / 0.09 s, kernels 1.0 s / 0.06 s
  • dinov2-b-linear-ade20k load / first call: original 12.01 s / 0.016 s (512x512), portable 0.27 s / 0.105 s, kernels 1.11 s / 0.067 s
  • dinov2-l-linear-ade20k load / first call: original 7.86 s / 0.382 s (512x512), portable 0.81 s / 0.156 s, kernels 1.83 s / 0.1 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5 (tools/speed_check.py), synthetic CUDA input (bench_inputs); peak = max over the first call and the timed calls

Measured

Each image at its own size, argmax of the logits. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
dinov2-s-linear-ade20kADE20K val, every 4th image, mIoU / aAcc %42.39 / 79.4042.38 / 79.4042.38 / 79.3942.39 / 79.4042.37 / 79.39
dinov2-b-linear-ade20kADE20K val, every 4th image, mIoU / aAcc %45.12 / 80.2945.12 / 80.2945.12 / 80.2845.12 / 80.2945.12 / 80.28
dinov2-l-linear-ade20kADE20K val, every 4th image, mIoU / aAcc %45.08 / 80.1345.09 / 80.1345.08 / 80.1345.08 / 80.1345.08 / 80.13

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 44640884, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Parity

CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 and p99 <= 0.25 (absolute error of the output logits).

variantkernels error vs original, mean / p99GPU, torchkernels used
dinov2-s-linear-ade20k0.00655 / 0.02391RTX 5060 Ti, torch 2.14.1+cu130dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, seg_up@3e44e71200cd:sm_120
dinov2-b-linear-ade20k0.01527 / 0.05855RTX 5060 Ti, torch 2.14.1+cu130dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, seg_up@3e44e71200cd:sm_120
dinov2-l-linear-ade20k0.01123 / 0.04402RTX 5060 Ti, torch 2.14.1+cu130dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, seg_up@3e44e71200cd:sm_120

Example output

One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti).

Input
Output
  • table 49%
  • plate 42%
  • floor 4.5%
  • wall 3.9%
  • sand 0.3%
A cup of coffee, input
Input · 100%

Input: A cup of coffee, Rachel Michetti (CC0).