Miscellaneous¶
Here are a couple of functions that are useful when writing an interface in a simulation engine to use metatomic models.
- metatomic.torch.pick_device(model_devices: List[str], desired_device: str | None) str[source]¶
Select the best device according to the list of
model_devicesfrom a model, the user-provideddesired_deviceand what’s available on the current machine.If
desired_deviceis provided, it is checked against themodel_devicesand the machine availability. If it contains a device index (e.g."cuda:1"), the base device type ("cuda") is used for these checks, and the full string is returned if successful.If
desired_deviceisNoneor an empty string, the first available device frommodel_deviceswill be picked and returned.