nvitop/examples/select-devices-api
2026-07-10 19:10:07 +08:00
..
README.md feat(examples): enrich the colored monitor and support uv run from a URL (#224) 2026-07-10 19:10:07 +08:00
select_devices_api.py feat(examples): enrich the colored monitor and support uv run from a URL (#224) 2026-07-10 19:10:07 +08:00

Programmatic CUDA Device Selection

Shows nvitop.select_devices — the Python API behind the nvisel CLI. Useful for scripts that need to pick GPUs based on free memory, utilization, or other criteria before launching a training job.

APIs Used

  • nvitop.select_devices — supports format='index' | 'uuid' | 'device', min_count, min_free_memory, max_gpu_utilization, and more.

Run

python3 examples/select-devices-api/select_devices_api.py

Or run it without cloning the repository, using uv:

uv run https://github.com/XuehaiPan/nvitop/raw/HEAD/examples/select-devices-api/select_devices_api.py

Requires only nvitop itself; no other dependencies.

See ../README.md for the full example index.