picture reader: allow 12 retries of the GPU context start (was 8)

The gate of the retry on a DGX Spark (4 starts counted with STRATA_VIT_PROF=1)
needed 5, 5, 5 and 6 retries, 5.4 to 6.8 s in all, about 1.1 to 1.2 s per
retry (the 1 s pause plus the failed attempt). 8 retries left a margin of 2.

Worst case when the context never comes: 12 retries, about 13 to 14.5 s of
waiting, then the reader fails as before and falls back as before.

The retry rule's test follows the constant.
This commit is contained in:
Niko1221 committed 2026-11-11 16:46:33 +01:00
1 parent 24e9d3ba82
commit 6d65761c4d
3 files changed
+5 -3

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
"""The picture reader's context retry (tools/vision/own/vit_gpu.cu, set_device_retrying) exists only in a Linux CUDA build.
A new CUDA context on a shared-memory GPU (DGX Spark) can fail with "out of memory" for a moment while the kernel has no free 2 MiB blocks; the reader
tries again up to 8 times, one second apart. The same cudaDevAttrIntegrated is true on AMD APUs (HIP build, same source file) and on Macs (a different
tries again up to 12 times, one second apart. The same cudaDevAttrIntegrated is true on AMD APUs (HIP build, same source file) and on Macs (a different
reader), and Windows has no such case, so the retry loop sits inside one guard, and the pure rule (vit_gpu.h) says no for everything but integrated + out of memory.
"""
import re
+1 -1
View File
@@ -51,7 +51,7 @@ int main(int argc, char** argv) {
CHECK(!vit_gpu_slower_amd("gfx1150") && !vit_gpu_slower_amd("gfx1201") && !vit_gpu_slower_amd("gfx11510") && !vit_gpu_slower_amd("gfx115") && !vit_gpu_slower_amd(""));
CHECK(vit_gpu_hip_windows_not_measured(true) && !vit_gpu_hip_windows_not_measured(false)); // Windows HIP keeps mtmd under auto; Linux HIP does not
{ // the context retry (vit_gpu.h): only "out of memory", only an integrated GPU, only a Linux CUDA build, at most kVitCtxRetries times
CHECK(kVitCtxRetries == 8 && kVitCtxWaitMs == 1000);
CHECK(kVitCtxRetries == 12 && kVitCtxWaitMs == 1000);
for (int done = 0; done < kVitCtxRetries; ++done) CHECK(vit_gpu_retry_context(true, true, true, done));
CHECK(!vit_gpu_retry_context(true, true, true, kVitCtxRetries) && !vit_gpu_retry_context(true, true, true, kVitCtxRetries + 5) && !vit_gpu_retry_context(true, true, true, -1));
CHECK(!vit_gpu_retry_context(false, true, true, 0)); // HIP, Windows, Metal: no retry
+3 -1
View File
@@ -47,7 +47,9 @@ inline bool vit_gpu_hip_windows_not_measured(bool windows) { return windows; }
// later succeeds (the kernel compacts memory in between; RESULTS-SPARK.md, 11-11: a probe context failed at 5 of 6 starts, every retry within 5 s succeeded).
// So VitGpu::load tries again, up to kVitCtxRetries times, kVitCtxWaitMs apart, and only for that error, on an integrated GPU, in a Linux CUDA build (an AMD APU under
// HIP and a Mac report "integrated" too; they are not this case). After the last retry it fails as before and the reader falls back as before. Pure function so the test needs no GPU.
constexpr int kVitCtxRetries = 8;
// 12 (gate 11-11: 4 counted starts needed 5, 5, 5 and 6 retries = 5.4 to 6.8 s, about 1.1 to 1.2 s per retry, the 1 s pause plus the failed attempt; 8 left 2 retries of margin). Worst case, when the
// context never comes: 12 retries, about 13 to 14.5 s of waiting, then the reader fails as before.
constexpr int kVitCtxRetries = 12;
constexpr int kVitCtxWaitMs = 1000;
inline bool vit_gpu_retry_context(bool linux_cuda_build, bool integrated_gpu, bool out_of_memory, int retries_done) {
return linux_cuda_build && integrated_gpu && out_of_memory && retries_done >= 0 && retries_done < kVitCtxRetries;