IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

Accelerator

Accelerator

class max.driver.Accelerator(self, id: int = -1)

source

Bases: Device

Creates an accelerator device with the specified ID and memory limit.

Provides access to GPU or other hardware accelerators in the system.

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:

Accelerator