dataeval.config.use_device¶
- dataeval.config.use_device(device)¶
Context manager to temporarily override the default device.
- Parameters:¶
- device : DeviceLike¶
The device to use within the context.
- Returns:¶
Context manager that restores the previous device on exit.
- Return type:¶
_ConfigContextManager
Examples
>>> with use_device("cuda:0"): ... # Operations here use cuda:0 ... get_device() device(type='cuda', index=0) >>> # Original device is restored >>> get_device() device(type='cpu')