diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 6088b323..a7c77d0e 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -1990,9 +1990,18 @@ int main(int argc, char** argv) { return 1; } void* arena = nullptr; - if (cudaMalloc(&arena, pool_bytes) != cudaSuccess) { - std::fprintf(stderr, "strata generate: cudaMalloc(%llu) for the weight arena failed\n", - (unsigned long long) pool_bytes); + if (const cudaError_t ce = cudaMalloc(&arena, pool_bytes); ce != cudaSuccess) { + // #486: the arena is the first large allocation and its size does not depend on the context, so what is + // missing is held by something else: say how much was free + cudaGetLastError(); + size_t free_b = 0, total_b = 0; + cudaMemGetInfo(&free_b, &total_b); + std::fprintf(stderr, "strata generate: cudaMalloc(%llu) for the weight arena failed (%s): %llu MiB of %llu " + "MiB VRAM free on this GPU. The arena is allocated first, before the KV and expert " + "caches: another program (or an engine that is still exiting) holds the rest - " + "nvidia-smi / rocm-smi lists them\n", + (unsigned long long) pool_bytes, cudaGetErrorString(ce), (unsigned long long) (free_b >> 20), + (unsigned long long) (total_b >> 20)); return 1; } strata::core::WeightTable wt; @@ -2297,8 +2306,14 @@ int main(int argc, char** argv) { void* arena_s = nullptr; if (cudaMalloc(&arena_s, pool_bytes) != cudaSuccess || !st.wt.load(o.pack, arena_s, pool_bytes, err, skip.empty() ? nullptr : &skip)) { - std::fprintf(stderr, "strata generate: layer split, CUDA%d weights: %s\n", st.dev, - err.empty() ? "the weight arena does not fit" : err.c_str()); + cudaGetLastError(); + size_t free_b = 0, total_b = 0; // #486: what that card had free + cudaMemGetInfo(&free_b, &total_b); + std::fprintf(stderr, "strata generate: layer split, CUDA%d weights: %s (%llu MiB needed, %llu MiB of %llu " + "MiB free on that card)\n", st.dev, + err.empty() ? "the weight arena does not fit" : err.c_str(), + (unsigned long long) (pool_bytes >> 20), (unsigned long long) (free_b >> 20), + (unsigned long long) (total_b >> 20)); return 1; } if (!o.native_dense_gguf.empty() && !st.dense.load(o.native_dense_gguf, st.wt, err, o.native_ple_key)) {