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_namearchitecture_version
property architecture_version
Returns the architecture version as an ArchitectureVersion.
Compare versions instead of parsing architecture_name:
- NVIDIA GPUs report the compute capability:
sm_100ais 10.0.0. - AMD GPUs report the processor version:
gfx950is 9.5.0 andgfx90ais 9.0.10. - Apple GPUs report the Apple silicon generation: an M5 is 5.0.0.
A virtual device for compile-only mode whose target is an
architecture name, such as sm_100a or gfx950, reports the
version of that architecture.
-
Raises:
-
ValueError – If the device is the CPU, if its API has no known numbering, or if its architecture name can’t be read, as for a virtual device whose target is an alias such as
mi355x.
from max import driver
device = driver.Accelerator()
version = device.architecture_versioncan_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.
memory_manager_stats
property memory_manager_stats
MLRT memory-manager allocation statistics for the device.
Keys: live_bytes, peak_live_bytes, max_request_bytes,
driver_fallbacks, driver_fallback_bytes and
request_sizes (distinct request sizes
of at least 256 MiB since the last reset). Every count is zero when
the memory manager is disabled.
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_namereset_memory_manager_peaks()
reset_memory_manager_peaks() → None
Restarts the memory manager’s peak statistics from its live bytes, and clears the largest request, the recorded request sizes and the driver fallback counts.
stats
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.