Skip to content

Fall back to the cuDNN heuristics when benchmarking runs out of memory - #3166

Merged
davisking merged 1 commit into
davisking:masterfrom
reunanen:fall-back-to-heuristics-when-benchmarking-runs-out-of-memory
Oct 3, 2026
Merged

davisking merged 1 commit into
davisking:masterfrom
reunanen:fall-back-to-heuristics-when-benchmarking-runs-out-of-memory

Conversation

@reunanen

@reunanen reunanen commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

When cudnnFind*Algorithm cannot allocate the GPU memory it needs for benchmarking, it fails with CUDNN_STATUS_INTERNAL_ERROR_DEVICE_ALLOCATION_FAILED (CUDNN_STATUS_ALLOC_FAILED before cuDNN 9), and the forward or backward pass fails with it.

Since #3162 each algorithm is chosen the first time it is needed, and with set_dnn_choose_algorithms_per_input_shape(true) again for each new input shape, so benchmarking can happen while the rest of the program is using the GPU. We hit this in CI, with two inference threads sharing a GPU.

In that case this falls back to the cudnnGet*Algorithm_v7 heuristics, and leaves the result out of the cache, so that the configuration is benchmarked properly the next time it comes up.

The cudnnFind*Algorithm functions allocate GPU memory to benchmark the candidate algorithms. Now that each algorithm is chosen the first time it is needed, and optionally for each input shape, that can happen while the rest of the program is using the GPU, and then the allocation can fail (CUDNN_STATUS_INTERNAL_ERROR_DEVICE_ALLOCATION_FAILED) and take the forward or backward pass down with it. Pick the algorithm with the cudnnGet*Algorithm_v7 heuristics instead then, and leave it out of the cache, so that the configuration gets benchmarked the next time.
@davisking

Copy link
Copy Markdown
Owner

Nice, thanks for another PR :D

@davisking
davisking merged commit 51670b7 into davisking:master Oct 3, 2026
11 checks passed
@reunanen
reunanen deleted the fall-back-to-heuristics-when-benchmarking-runs-out-of-memory branch October 4, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants