Models · Promptable segmentation

Segment Anything (SAM)

Segment Anything: masks from clicks, boxes or mask prompts, in sizes B, L and H. Commercially usable.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
sam-vit-bsynthetic (1024x1024)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
168
98.2
48.3
37.0
40.9
27.3 (image encoder only)
2798 / 2832
1769 / 1802
378 / 420
377 / 420
362 / 400
322 (engine)
sam-vit-lsynthetic (1024x1024)original (fp32)
original
portable
kernels
406
197
116
81.5
4428 / 4474
3411 / 3464
833 / 1262
831 / 862
sam-vit-hsynthetic (1024x1024)original (fp32)
original
portable
kernels
734
306
214
143
5702 / 5754
5295 / 5404
1484 / 2524
1480 / 1524
Details
  • Original code: https://github.com/facebookresearch/segment-anything at dca509f
  • Code licence: Apache-2.0 (permissive); files: LICENSE
  • Weights licence: Apache-2.0
  • Licence evidence: https://github.com/facebookresearch/segment-anything/blob/main/README.md (License section: model checkpoints and code under Apache 2.0)
  • Training data: SA-1B (11M licensed images, 1.1B automatically generated masks) per the paper; the dataset itself is under the SA-1B research licence
  • Kernel libraries: dpt_fused
  • Variants: sam-vit-b, sam-vit-l, sam-vit-h
  • Outputs: pred_masks, iou_scores
  • Input size: any H x W >= 1, resized inside to the fixed encoder input 1024x1024 (the default export size)
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): sam-vit-b 1080x1920 (0.4 GiB peak allocated, 0.5 reserved); sam-vit-l 1080x1920 (0.8 GiB peak allocated, 1.0 reserved); sam-vit-h 1080x1920 (1.5 GiB peak allocated, 1.9 reserved)
  • sam-vit-b 1024x1024, first call: portable + torch.compile 15 s (cold Inductor cache), TensorRT fp16 36 s (ONNX + engine).
  • sam-vit-b original 1024x1024: torch.autocast(float16) around the call
  • sam-vit-l original 1024x1024: torch.autocast(float16) around the call
  • sam-vit-h original 1024x1024: torch.autocast(float16) around the call
  • sam-vit-b load / first call: original 0.75 s / 0.176 s, portable 0.46 s / 0.048† s, kernels 0.17† s / 0.037† s
  • sam-vit-l load / first call: original 1.8 s / 0.268 s, portable 1.21 s / 0.116† s, kernels 0.43† s / 0.081† s
  • sam-vit-h load / first call: original 4.61 s / 0.376 s, portable 2.45 s / 0.214† s, kernels 0.89† s / 0.143† s
  • † measured in the speed sweep after the portable load (or an earlier size) in the same process: file cache and kernels are warm, so the time is lower than a fresh start.
  • Protocol, median of 5 after 3 warm-up, uint8 CUDA input (synthetic for bench_inputs sizes), card defaults; gc before each load; peak = max over the first call and the timed calls

Measured

One point per ground-truth instance (the interior point farthest from the border); IoU of the best-scored of 3 masks / of the single mask. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portablekernelsnote
sam-vit-bCOCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask %52.91 / 50.3153.08 / 50.3952.91 / 50.3152.89 / 50.32
sam-vit-lCOCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask %57.89 / 53.3257.76 / 53.3157.84 / 53.3257.85 / 53.33
sam-vit-hCOCO val2017, every 10th image, point prompts, mIoU best of 3 / single mask %57.93 / 53.1357.92 / 53.1357.97 / 53.1257.99 / 53.12

Measured on 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| <= 3 % and p99 <= 15 % of the reference's median |value| (absolute error of the output pred_masks).

variantkernels error vs original, mean / p99GPU, torchkernels used
sam-vit-b0.00044 / 0.00203RTX 5060 Ti, torch 2.14.1+cu130dpt_fused@48e0065bb7cf:sm_120
sam-vit-l0.01589 / 0.06758RTX 5060 Ti, torch 2.14.1+cu130dpt_fused@48e0065bb7cf:sm_120
sam-vit-h0.00329 / 0.01177RTX 5060 Ti, torch 2.14.1+cu130dpt_fused@48e0065bb7cf:sm_120