diff --git a/engine/src/ling32/ling32_main.cpp b/engine/src/ling32/ling32_main.cpp index f507dfd789..34c841956d 100644 --- a/engine/src/ling32/ling32_main.cpp +++ b/engine/src/ling32/ling32_main.cpp @@ -800,6 +800,7 @@ int cmd_run(const RunOpts& o_in) { } uint64_t win_pin_cap = 0; // Windows with a discrete card: how much RAM the planner may give the pinned RAM tier #if defined(_WIN32) + RunOpts plan_opts = o; // the options of the first plan (the RAM budget cut to the pin cap below): the replan after --mtp-auto dropped the sidecar starts from this copy, not from the plain options if (!win_igpu && o.tier != "vram") { // The driver page-locks only part of the system RAM for the GPU (it stops at about half of it, and the commit limit is RAM + page file): a 34 GiB cudaHostAlloc failed with "out of memory" on a // 63 GB PC with 43 GB free (the planner had offered all free RAM minus 6 GiB). Plan the RAM tier within the free RAM minus 8 GiB for Windows and at most half of the system RAM minus 0.5 GiB @@ -817,7 +818,9 @@ int cmd_run(const RunOpts& o_in) { #endif if (!o.map_experts && (!integrated || asked || (win_igpu && o.tier != "vram"))) { std::string perr; +#if !defined(_WIN32) RunOpts plan_opts = o; +#endif if (win_igpu && o.tier != "vram" && o.ram_budget_gib <= 0 && win_ram_budget > 0) plan_opts.ram_budget_gib = win_ram_budget / double(1ull << 30); if (win_pin_cap > 0) { const double cap_gib = win_pin_cap / double(1ull << 30); @@ -845,7 +848,16 @@ int cmd_run(const RunOpts& o_in) { o.spec_mtp = false; o.spec = false; // the speculative loop is the drafter's: a plain run follows if (tiered) { // the plan counted the sidecar's bytes: plan again without it +#if defined(_WIN32) + // the first plan cut the RAM tier to the Windows pin cap (the GPU driver pins no more than about half of the system RAM); planning again from the plain options dropped the cap: a B70 PC pinned 16.9 GiB + // of 32 GB RAM and every device allocation after the tier store failed with UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY (Load: "cudaMemset: SYCL runtime error"). Replan from the capped copy, the sidecar removed + RunOpts po = plan_opts; + po.mtp_file.clear(); + po.spec_mtp = false; + po.spec = false; +#else RunOpts po = o; +#endif std::string perr2; if (make_plan(f, po, plan_vram, plan_ram, plan, rt, perr2)) { std::printf("%s\n", plan.describe().c_str()); tiered = plan.mode != TierMode::A; } }