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
Device
Device
class max.driver.Device
Bases: object
Represents a compute device available for tensor operations.
This is the base class for CPU and Accelerator.
Do not instantiate this class directly; use CPU for host
devices and Accelerator for any hardware accelerator.
from max import driver
cpu = driver.CPU()
device = driver.Accelerator() if driver.accelerator_count() else driver.CPU()api
property api
Returns the API used to program the device.
Possible values are:
cpufor host devices.cudafor NVIDIA GPUs.hipfor AMD GPUs.metalfor Apple GPUs.
from max import driver
device = driver.Accelerator() if driver.accelerator_count() else driver.CPU()
device.apiarchitecture_name
property architecture_name
Returns the architecture name of the device.
Examples of possible values:
gfx90a,gfx942for AMD GPUs.sm_80,sm_86for NVIDIA GPUs.- CPU devices raise an exception.
from max import driver
device = driver.Accelerator()
device.architecture_namecan_access()
can_access(other: max.driver.Device) → bool
Checks if this device can directly access memory of another device.
from max import driver
gpu0 = driver.Accelerator(id=0)
gpu1 = driver.Accelerator(id=1)
if gpu0.can_access(gpu1):
print("GPU0 can directly access GPU1 memory.")-
Parameters:
-
other – The other device to check peer access against.
-
Returns:
-
Trueif peer access is possible,Falseotherwise.
cpu()
cpu(id: int = 0) → max.driver.CPU
Creates a CPU device.
-
Parameters:
-
id – The device ID. Currently ignored.
default_queue
property default_queue
Returns the default queue for this device.
The default queue is initialized when the device object is created.
-
Returns:
-
The default execution queue for this device.
id
property id
Returns a zero-based device id.
For a CPU device this is always 0.
For GPU accelerators this is the ID of the device relative to this host.
Along with the label, an ID can uniquely identify a device,
such as gpu:0 or gpu:1.
from max import driver
device = driver.Accelerator() if driver.accelerator_count() else driver.CPU()
device_id = device.id-
Returns:
-
The device ID.
is_compatible
property is_compatible
Returns whether this device is compatible with MAX.
-
Returns:
-
Trueif the device is compatible with MAX,Falseotherwise.
is_host
property is_host
Whether this device is the CPU (host) device.
from max import driver
device = driver.Accelerator() if driver.accelerator_count() else driver.CPU()
device.is_hostis_host_unified
property is_host_unified
Whether this device and the host draw from one physical memory pool.
Reports hardware topology, so it does not predict whether a particular buffer is readable from the host.
from max import driver
device = driver.Accelerator() if driver.accelerator_count() else driver.CPU()
device.is_host_unifiedlabel
property label
Returns device label.
Possible values are:
cpufor host devices.gpufor accelerators.
from max import driver
device = driver.Accelerator() if driver.accelerator_count() else driver.CPU()
device.labelmax_single_alloc_size
property max_single_alloc_size
Largest single contiguous allocation, in bytes.
model_name
property model_name
Returns the model name of the device.
Examples of possible values:
NVIDIA H100 80GB HBM3for an H100.NVIDIA B200for a B200.AMD Instinct MI300Xfor an MI300X.cpufor a CPU device.
from max import driver
device = driver.Accelerator() if driver.accelerator_count() else driver.CPU()
device.model_namestats
property stats
Returns utilization data for the device.
from max import driver
device = driver.Accelerator() if driver.accelerator_count() else driver.CPU()
stats = device.stats-
Returns:
-
A dictionary containing device utilization statistics.
synchronize()
synchronize() → None
Ensures all operations on this device complete before returning.
-
Raises:
-
ValueError – If any enqueued operations had an internal error.