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)
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,2or lists of integers like[0, 1, 2]. -
Returns:
-
the slot count implied by the highest GPU index in the raw inputs, with a floor of
1. In particular,gpu:allwhenaccelerator_count()is0leavesmax_gpu_id == -1and still returns1(same as no GPU IDs in the CLI). That floor is for virtual-device setup; actualgpu:allwith zero GPUs still fails later when device specs are built. -
Return type:
-
max(1, max_gpu_id + 1)
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!