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 function

calculate_virtual_device_count_from_cli

calculate_virtual_device_count_from_cli()

max.driver.calculate_virtual_device_count_from_cli(*device_inputs)

source

Calculates the minimum virtual device count from raw CLI inputs (before parsing).

This helper works with the raw device input strings or lists before they’re parsed into DeviceSpec objects. Used when virtual device mode needs to be enabled before device validation occurs.

Parameters:

*device_inputs (str | list[int]) – One or more raw device inputs, either strings like gpu:0,1,2 or lists of integers like [0, 1, 2].

Returns:

The minimum number of virtual devices needed (max GPU ID + 1), or 1 if no GPUs.

Return type:

int