]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama-bench : use local GPUs along with RPC servers (#14917)
authorRadoslav Gerganov <redacted>
Mon, 28 Jul 2025 15:59:04 +0000 (18:59 +0300)
committerGitHub <redacted>
Mon, 28 Jul 2025 15:59:04 +0000 (18:59 +0300)
Currently if RPC servers are specified with '--rpc' and there is a local
GPU available (e.g. CUDA), the benchmark will be performed only on the
RPC device(s) but the backend result column will say "CUDA,RPC" which is
incorrect. This patch is adding all local GPU devices and makes
llama-bench consistent with llama-cli.

tools/llama-bench/llama-bench.cpp

index b80e984d0245b97009bbbb41e8cb6dbcc769fb26..c56834a2a6e4d5e079f521129b6601759c1b146f 100644 (file)
@@ -950,6 +950,7 @@ struct cmd_params_instance {
                 }
                 static std::vector<ggml_backend_dev_t> devices;
                 devices.clear();
+                // RPC devices should always come first for performance reasons
                 for (const std::string & server : rpc_servers) {
                     ggml_backend_dev_t dev = ggml_backend_rpc_add_device_fn(server.c_str());
                     if (dev) {
@@ -959,6 +960,20 @@ struct cmd_params_instance {
                         exit(1);
                     }
                 }
+                // add local GPU devices if any
+                for (size_t i = 0; i < ggml_backend_dev_count(); ++i) {
+                    ggml_backend_dev_t dev = ggml_backend_dev_get(i);
+                    switch (ggml_backend_dev_type(dev)) {
+                        case GGML_BACKEND_DEVICE_TYPE_CPU:
+                        case GGML_BACKEND_DEVICE_TYPE_ACCEL:
+                            // skip CPU backends since they are handled separately
+                            break;
+
+                        case GGML_BACKEND_DEVICE_TYPE_GPU:
+                            devices.push_back(dev);
+                            break;
+                    }
+                }
                 devices.push_back(nullptr);
                 mparams.devices = devices.data();
             }