For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python class
Accelerator
Accelerator
class max.driver.Accelerator(self, id: int = -1)
Bases: Device
Creates an accelerator device with the specified ID and memory limit.
Represents any hardware accelerator attached to the host: the
graph compiler reaches CUDA, HIP, Metal and plugin-provided
backends alike through this one device class. Use
isinstance(device, Accelerator) to mean “any non-CPU device”,
and api to tell the concrete backends apart.
Repeated instantiations with a previously-used device-id will still refer to the first such instance that was created. This is especially important when providing a different memory limit: only the value (implicitly or explicitly) provided in the first such instantiation is effective.
from max import driver
device = driver.Accelerator()
# Or specify GPU id
device = driver.Accelerator(id=0) # First GPU
device = driver.Accelerator(id=1) # Second GPU
# Get device id
device_id = device.id-
Parameters:
-
id (int, optional) – The device ID to use. Defaults to -1, which selects the first available accelerator.
-
Returns:
-
A new Accelerator device object.
-
Return type: