From 923f77851f7cb887f254627999bac85c2c90b563 Mon Sep 17 00:00:00 2001 From: Juha Reunanen Date: Mon, 29 Dec 2025 16:55:58 +0200 Subject: [PATCH] Problem: on Blackwell GPUs, functions such as `cudnnFindConvolutionBackwardDataAlgorithm` may run out of stack space on Windows (leading to a stack overflow error) Solution: increase the stack size from the default 1 MB to 16 MB (yea, 8 MB wasn't enough, at least on my machine...) --- examples/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1232d58b09..57486cd11a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -112,6 +112,16 @@ macro(add_example name) # required though. target_link_options(${name} PRIVATE $<$:-s>) endif() + + if (MSVC) + # For DNN builds on Visual C++, increase the stack size from the default 1 MB - + # because otherwise there may easily be a stack overflow error (0xC00000FD) when + # calling cudnnFindConvolutionBackwardDataAlgorithm (and/or friends) on Blackwell + # (where calling these "Find" functions may result in a deep recursive search). + if (${name} MATCHES "dnn_.*_ex") + set_target_properties(${name} PROPERTIES LINK_FLAGS "/STACK:16777216") + endif() + endif() endmacro() # if an example requires GUI, call this macro to check DLIB_NO_GUI_SUPPORT to include or exclude