mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-11 03:24:30 +00:00
fix: include RPC devices in --list-devices (#2182)
This commit is contained in:
1 parent
2e2ba3faec
commit
b15c8aac39
7 files changed
+50
-20
No files matched your search
@@ -301,6 +301,10 @@ void parse_args(int argc, const char** argv, SDCliParams& cli_params, SDContextP
|
||||
log_level = cli_params.log_level;
|
||||
log_color = cli_params.color;
|
||||
|
||||
if (ctx_params.list_devices) {
|
||||
exit(ctx_params.print_devices() ? 0 : 1);
|
||||
}
|
||||
|
||||
bool valid = cli_params.resolve_and_validate();
|
||||
if (valid && cli_params.mode != METADATA) {
|
||||
valid = ctx_params.resolve_and_validate(cli_params.mode) &&
|
||||
|
||||
+16
-12
@@ -596,6 +596,11 @@ ArgOptions SDContextParams::get_options() {
|
||||
};
|
||||
|
||||
options.bool_options = {
|
||||
{"",
|
||||
"--list-devices",
|
||||
"list available ggml backend devices, including --rpc-servers (one 'name<TAB>description' per line), and exit; "
|
||||
"the names are the device names accepted by --backend and --params-backend",
|
||||
true, &list_devices},
|
||||
{"",
|
||||
"--disable-prefetch",
|
||||
"disable asynchronous next-segment weight prefetch (defaults to false)",
|
||||
@@ -819,23 +824,22 @@ ArgOptions SDContextParams::get_options() {
|
||||
"but it usually offers faster inference speed and, in some cases, lower memory usage. "
|
||||
"The at_runtime mode, on the other hand, is exactly the opposite.",
|
||||
on_lora_apply_mode_arg},
|
||||
{"",
|
||||
"--list-devices",
|
||||
"list available ggml backend devices (one 'name<TAB>description' per line) and exit; "
|
||||
"the names are the device names accepted by --backend and --params-backend",
|
||||
[](int /*argc*/, const char** /*argv*/, int /*index*/) {
|
||||
size_t device_list_size = sd_list_devices(nullptr, 0);
|
||||
std::vector<char> devices(device_list_size + 1);
|
||||
sd_list_devices(devices.data(), devices.size());
|
||||
fputs(devices.data(), stdout);
|
||||
std::exit(0);
|
||||
return 0;
|
||||
}},
|
||||
};
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
bool SDContextParams::print_devices() const {
|
||||
if (!sd_add_rpc_servers(rpc_servers.c_str())) {
|
||||
return false;
|
||||
}
|
||||
size_t device_list_size = sd_list_devices(nullptr, 0);
|
||||
std::vector<char> devices(device_list_size + 1);
|
||||
sd_list_devices(devices.data(), devices.size());
|
||||
fputs(devices.data(), stdout);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDContextParams::build_embedding_map() {
|
||||
static const std::vector<std::string> valid_ext = {".gguf", ".safetensors", ".pt", ".ckpt"};
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ struct SDContextParams {
|
||||
std::string model_args;
|
||||
bool auto_fit = true;
|
||||
std::string rpc_servers;
|
||||
bool list_devices = false;
|
||||
std::string effective_backend;
|
||||
std::string effective_params_backend;
|
||||
bool enable_mmap = false;
|
||||
@@ -189,6 +190,7 @@ struct SDContextParams {
|
||||
|
||||
float flow_shift = INFINITY;
|
||||
ArgOptions get_options();
|
||||
bool print_devices() const;
|
||||
void build_embedding_map();
|
||||
void prepare_backend_assignments();
|
||||
bool resolve(SDMode mode);
|
||||
|
||||
@@ -48,6 +48,10 @@ static void parse_args(int argc,
|
||||
log_level = svr_params.log_level;
|
||||
log_color = svr_params.color;
|
||||
|
||||
if (ctx_params.list_devices) {
|
||||
exit(ctx_params.print_devices() ? 0 : 1);
|
||||
}
|
||||
|
||||
const bool random_seed_requested = default_gen_params.seed < 0;
|
||||
|
||||
if (!svr_params.resolve_and_validate() ||
|
||||
|
||||
Reference in new issue
Block a user