mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-06 08:18:54 +00:00
When cudaHostRegister refuses the whole expert arena, the sliced fallback
pinned layer after layer until the driver refused one (28 GiB on a 63 GB
single-GPU PC), and WDDM then refused every later device allocation
("native head upload: out of memory"). On Windows the sliced pass now stops
at the adapter's DXGI non-local budget - the process's current usage - 4 GiB
(IDXGIAdapter3::QueryVideoMemoryInfo for the CUDA device's LUID; dxgi.dll is
loaded at run time), or RAM/2 - 8 GiB when that query fails. The arena line
names the cap and where it came from.
STRATA_ARENA_PIN_GIB: unset = the above; 0 = no cap (the old behaviour);
N > 0 = at most N GiB from the start. arena_pin_cap_gib() (pinned.hpp)
reads it, -1 when unset, for the multi-GPU cap in generate.cpp as well.
A machine whose whole-arena registration succeeds is unchanged, and a
caller's cap (multi-GPU) still takes precedence.
This PC's whole registration fails too: IQ3_XXS now pins 24 GiB (32 slices;
budget 30.8 GiB - 2.0 in use - 4) instead of 28 GiB (36).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0154bwiad8gY7wRehCXy27pN
36 lines
1.7 KiB
C++
36 lines
1.7 KiB
C++
// include/strata/platform/memory.hpp - plan v0.3 P0.1/P1: keep a large host region resident.
|
|
//
|
|
// `cudaHostRegister` refuses the 31.6 GiB expert arena on Windows, and an unlocked arena is trimmed under memory
|
|
// pressure (the CPU pool then swung 2x between runs). With the n-gram table out of RAM there is headroom to lock
|
|
// it instead: raise the process's minimum working set by the region's size, then VirtualLock it (Windows needs
|
|
// only SeIncreaseWorkingSetPrivilege, which ordinary accounts hold). Linux: mlock.
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace strata::platform {
|
|
|
|
struct LockResult {
|
|
bool ok = false;
|
|
uint64_t locked_bytes = 0; ///< may be less than requested; the rest stays pageable
|
|
std::string note; ///< what was done or why it failed, for the startup print
|
|
};
|
|
|
|
/// Lock [p, p + bytes) into physical memory. Partial success is reported, not hidden.
|
|
LockResult lock_resident(void* p, uint64_t bytes);
|
|
|
|
/// Undo lock_resident for the same region (best effort).
|
|
void unlock_resident(void* p, uint64_t bytes);
|
|
|
|
/// #243, Windows: the GPU's shared (non-local) memory budget and this process's use of it, from DXGI
|
|
/// (IDXGIAdapter3::QueryVideoMemoryInfo, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL) for the adapter whose LUID is the
|
|
/// 8 bytes at `luid` (cudaDeviceProp::luid). Page-locked host memory the GPU maps is charged there. False (and
|
|
/// `why` says so) when the query is not possible - always elsewhere than Windows.
|
|
bool gpu_shared_memory_budget(const void* luid, uint64_t& budget, uint64_t& usage, std::string& why);
|
|
|
|
/// The machine's physical RAM in bytes (0 when unknown).
|
|
uint64_t total_physical_memory();
|
|
|
|
} // namespace strata::platform
|