Skip to main content

Module sniff

Module sniff 

Source
Expand description

Picking a backend that actually works on this machine.

A build can enable several accelerators, but only some of them will run on any given machine. A CUDA build on a machine with no Nvidia driver, for instance, compiles fine and then fails at runtime.

sniff_best_accelerator takes a list in order of preference and returns the first one that really starts on the device the caller asked for, so callers can list a fast backend followed by a safe fallback.

The probe runs on that device rather than on the backend’s default one. Opening a client is what proves a backend works, and opening it on a card the caller did not choose both tests the wrong hardware and pays that card’s first-time driver initialisation.

Denoiser::create calls this for you, so reach for it directly only when you want to know the answer without building a denoiser.

use av_denoise_core::Device;
use av_denoise_core::accelerate::get_default_accelerators;
use av_denoise_core::sniff::sniff_best_accelerator;

match sniff_best_accelerator(&get_default_accelerators(), &Device::Default) {
    Some(accelerator) => println!("running on {accelerator}"),
    None => println!("no usable backend on this machine"),
}

Functions§

sniff_best_accelerator
Tries each accelerator in turn and returns the first one whose client can be built and synchronised on device.