arg : list RPC devices first when using --list-devices (#11655)
List devices in the same order as they appear when evaluating the model and splitting tensors across devices, i.e. RPC devices come first in the list. ref #11435
This commit is contained in:
parent
db288b60cb
commit
1bef571f6a
1 changed files with 17 additions and 4 deletions
|
@ -1465,15 +1465,28 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
|
||||||
{"--list-devices"},
|
{"--list-devices"},
|
||||||
"print list of available devices and exit",
|
"print list of available devices and exit",
|
||||||
[](common_params &) {
|
[](common_params &) {
|
||||||
printf("Available devices:\n");
|
std::vector<ggml_backend_dev_t> rpc_devices;
|
||||||
|
std::vector<ggml_backend_dev_t> all_devices;
|
||||||
for (size_t i = 0; i < ggml_backend_dev_count(); ++i) {
|
for (size_t i = 0; i < ggml_backend_dev_count(); ++i) {
|
||||||
auto * dev = ggml_backend_dev_get(i);
|
auto * dev = ggml_backend_dev_get(i);
|
||||||
if (ggml_backend_dev_type(dev) == GGML_BACKEND_DEVICE_TYPE_GPU) {
|
if (ggml_backend_dev_type(dev) == GGML_BACKEND_DEVICE_TYPE_GPU) {
|
||||||
|
ggml_backend_reg_t reg = ggml_backend_dev_backend_reg(dev);
|
||||||
|
if (ggml_backend_reg_name(reg) == std::string("RPC")) {
|
||||||
|
rpc_devices.push_back(dev);
|
||||||
|
} else {
|
||||||
|
all_devices.push_back(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// insert RPC devices in front
|
||||||
|
all_devices.insert(all_devices.begin(), rpc_devices.begin(), rpc_devices.end());
|
||||||
|
printf("Available devices:\n");
|
||||||
|
for (size_t i = 0; i < all_devices.size(); ++i) {
|
||||||
|
auto * dev = all_devices[i];
|
||||||
size_t free, total;
|
size_t free, total;
|
||||||
ggml_backend_dev_memory(dev, &free, &total);
|
ggml_backend_dev_memory(dev, &free, &total);
|
||||||
printf(" %s: %s (%zu MiB, %zu MiB free)\n", ggml_backend_dev_name(dev), ggml_backend_dev_description(dev), total / 1024 / 1024, free / 1024 / 1024);
|
printf(" %s: %s (%zu MiB, %zu MiB free)\n", ggml_backend_dev_name(dev), ggml_backend_dev_description(dev), total / 1024 / 1024, free / 1024 / 1024);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue