device#
Torch device selection shared by enrichment detectors.
Functions#
|
Select the best available inference device: cuda, DirectML, or CPU. |
Module Contents#
- openplaces.io.enricher.detectors.device.get_device(force: str | None = None)#
Select the best available inference device: cuda, DirectML, or CPU.
The choice is printed once per process so a silent CPU fallback is visible instead of looking like a hang.
- Parameters:
force (str, optional) – Device string (e.g. ‘cpu’, ‘cuda:0’) that overrides detection. The OPENPLACES_DEVICE environment variable plays the same role when set.
- Returns:
CUDA when an NVIDIA GPU is available (ROCm builds also surface here), otherwise DirectML when the optional torch_directml package is importable (AMD/Intel GPUs on Windows; never install it into the main conda env), otherwise CPU.
- Return type:
torch.device