Skip to main content

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