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 or Accelerator for GPU devices.
from max import driver
cpu = driver.CPU()
gpu = driver.Accelerator()api
property api
Returns the API used to program the device.
Possible values are:
cpufor host devices.cudafor NVIDIA GPUs.hipfor AMD GPUs.
from max import driver
device = 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(self, 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.")cpu
cpu = <nanobind.nb_func object>
default_stream
property default_stream
Returns the default stream for this device.
The default stream is initialized when the device object is created.
-
Returns:
-
The default execution stream for this device.
-
Return type:
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,
e.g. gpu:0, gpu:1.
from max import driver
device = driver.Accelerator()
device_id = device.id-
Returns:
-
The device ID.
-
Return type:
is_compatible
property is_compatible
Returns whether this device is compatible with MAX.
-
Returns:
-
True if the device is compatible with MAX, False otherwise.
-
Return type:
is_host
property is_host
Whether this device is the CPU (host) device.
from max import driver
device = driver.CPU()
device.is_hostlabel
property label
Returns device label.
Possible values are:
cpufor host devices.gpufor accelerators.
from max import driver
device = driver.CPU()
device.labelstats
property stats
Returns utilization data for the device.
from max import driver
device = driver.CPU()
stats = device.stats-
Returns:
-
A dictionary containing device utilization statistics.
-
Return type:
synchronize()
synchronize(self) → None
Ensures all operations on this device complete before returning.
-
Raises:
-
ValueError – If any enqueued operations had an internal error.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!