Skip to content

Add --list-devices-format json for --list-devices - #23676

Closed
gaugarg-nv wants to merge 1 commit into
ggml-org:masterfrom
gaugarg-nv:extend_list_device
Closed

gaugarg-nv wants to merge 1 commit into
ggml-org:masterfrom
gaugarg-nv:extend_list_device

Conversation

@gaugarg-nv

Copy link
Copy Markdown
Contributor

Produce a more detailed, machine-readable GGML device list that includes devices, backend names, props, caps, memory, and backend feature flags.

CUDA/ROCm also exposes per-device attributes such as compute capability or gfx target via a new optional backend-attribute hook. This can be extended further to include other important device attributes.

This is helpful to get all the important runtime device information and compile flags with a single command.

The new output looks like this-

./llama-cli --list-devices --list-devices-format json
{
  "schema_version": 1,
  "devices": [
    {
      "index": 0,
      "backend": "CUDA",
      "name": "CUDA0",
      "description": "NVIDIA GeForce RTX 5090",
      "type": "GPU",
      "device_id": "0000:02:00.0",
      "memory_total": 33670758400,
      "memory_free": 33124450304,
      "caps": {
        "async": true,
        "host_buffer": true,
        "buffer_from_host_ptr": false,
        "events": true
      },
      "attributes": {
        "compute_capability": "12.0"
      }
    },
    {
      "index": 1,
      "backend": "CUDA",
      "name": "CUDA1",
      "description": "NVIDIA GeForce RTX 5090",
      "type": "GPU",
      "device_id": "0000:03:00.0",
      "memory_total": 33661911040,
      "memory_free": 33040105472,
      "caps": {
        "async": true,
        "host_buffer": true,
        "buffer_from_host_ptr": false,
        "events": true
      },
      "attributes": {
        "compute_capability": "12.0"
      }
    },
    {
      "index": 2,
      "backend": "CPU",
      "name": "CPU",
      "description": "Intel(R) Core(TM) Ultra 9 285K",
      "type": "CPU",
      "device_id": null,
      "memory_total": 134293438464,
      "memory_free": 134293438464,
      "caps": {
        "async": false,
        "host_buffer": false,
        "buffer_from_host_ptr": true,
        "events": false
      },
      "attributes": {}
    }
  ],
  "backends": [
    {
      "name": "CUDA",
      "features": {
        "ARCHS": "1200",
        "USE_GRAPHS": "1",
        "PEER_MAX_BATCH_SIZE": "128",
        "BLACKWELL_NATIVE_FP4": "1"
      }
    },
    {
      "name": "CPU",
      "features": {
        "LLAMAFILE": "1",
        "OPENMP": "1",
        "REPACK": "1"
      }
    }
  ]
}

Requirements

Produce a more detailed, machine-readable GGML device list that includes devices, backend names, props, caps, memory, and backend feature flags.

CUDA/ROCm also exposes per-device attributes such as compute capability or gfx target via a new optional backend-attribute hook. This can be extended further to include other important device attributes.
@gaugarg-nv
gaugarg-nv requested review from a team and ggerganov as code owners May 25, 2026 16:48
@github-actions github-actions Bot added Nvidia GPU Issues specific to Nvidia GPUs ggml changes relating to the ggml tensor library for machine learning labels May 25, 2026
@gaugarg-nv gaugarg-nv changed the title Add --list-devices-format json for --list-device Add --list-devices-format json for --list-devices May 25, 2026
@am17an

am17an commented May 25, 2026

Copy link
Copy Markdown
Contributor

What's the intended downstream use-case for this? If it's for humans then something apart from JSON would be preferred perhaps

@gaugarg-nv

Copy link
Copy Markdown
Contributor Author

What's the intended downstream use-case for this? If it's for humans then something apart from JSON would be preferred perhaps

The primary use case is for bug reporting, for which a human-readable string is fine too.
Another important use case that we are working on internally is to use this information in automated test runners to filter models, quant types (Blackwell-FP4), etc on specific GPUs. For this, a machine-readable string will be preferred.

I'd imagine this will also be useful for 3rd party apps, which are written on top of Llama.cpp, to filter or prioritize the right devices based on available memory and compute capability. This will also enable filtering of models if a model is too large to fit in the available memory.

@JohannesGaessler

Copy link
Copy Markdown
Contributor

My opinion is that something like this should be added when there is a concrete use case, otherwise I don't think we can justify the opportunity cost.

@gaugarg-nv

Copy link
Copy Markdown
Contributor Author

I think there are concrete use cases for this functionality, and I expect downstream projects to adopt it once it becomes available.

  • This request came from our automation team, which needs a way to filter models and GPUs.
  • We’ve also received similar feedback from other downstream users of llama.cpp. We are working with both internal and external teams that integrate with llama.cpp, and they have expressed the need for this to enable a cleaner and more robust implementation.
  • Downstream projects such as Ollama and LMStudio currently implement their own device discovery logic, which often leads to issues. I found multiple GitHub issues reported by end users that are directly related to GPU discovery problems.

IMO, the change is also fairly simple and isolated and shouldn't have much maintenance overhead.

@ngxson

ngxson commented May 29, 2026 •

Copy link
Copy Markdown
Collaborator

We had a discussion internally last month about the same feature but at broader level, a --json that allow reporting multiple outputs as json

I think it should better be a generic feature than something specific to one use case. So I think we can temporarily close this PR for now and wait until we can refactor the code a bit to generalize it.

cc @julien-c for visibility

@ngxson

ngxson commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

FYI, I implemented a more flexible version of this idea in #28586

it can be extended to log anything that an external application might want to use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning Nvidia GPU Issues specific to Nvidia GPUs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants