Skip to content

Commit d7b5465

Browse files
committed
Bump Windows max open files from 512 to 2048
ikawrakow/ik_llama.cpp#620
1 parent 7d6418b commit d7b5465

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/llama-model-loader.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,17 @@ llama_model_loader::llama_model_loader(
478478
trace = atoi(getenv("LLAMA_TRACE"));
479479
}
480480

481+
#ifdef _WIN32
482+
// Cap at MSVC's hard limit of 8192 - https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio?view=msvc-160
483+
#define _GGML_STDIO_TARGET 2048
484+
int _setmaxstdio_ret = _setmaxstdio(_GGML_STDIO_TARGET);
485+
if (_setmaxstdio_ret == -1) {
486+
LLAMA_LOG_INFO("%s: failed to set max stdio to %d. (setmaxstdio returned -1)\n", __func__, _GGML_STDIO_TARGET);
487+
} else {
488+
LLAMA_LOG_INFO("%s: max stdio successfully set to %d\n", __func__, _setmaxstdio_ret);
489+
}
490+
#endif // _WIN32
491+
481492
if (param_overrides_p != nullptr) {
482493
for (const struct llama_model_kv_override * p = param_overrides_p; p->key[0] != 0; p++) {
483494
kv_overrides.insert({std::string(p->key), *p});

0 commit comments

Comments
 (0)