Improve error message for ManagedMemoryResource() on unsupported platforms#1835
Open
Andy-Jost wants to merge 1 commit intoNVIDIA:mainfrom
Open
Improve error message for ManagedMemoryResource() on unsupported platforms#1835Andy-Jost wants to merge 1 commit intoNVIDIA:mainfrom
Andy-Jost wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Andy-Jost
commented
Mar 30, 2026
Comment on lines
+260
to
+263
| raise RuntimeError( | ||
| "Getting the current memory pool for a memory location and " | ||
| "allocation type requires CUDA 13.0 or later" | ||
| ) |
Contributor
Author
There was a problem hiding this comment.
Unrelated fix, but a needed improvement.
When ManagedMemoryResource() is called without options on a platform where the default memory pool does not support managed allocations (e.g. WSL2), the error from cuMemGetMemPool is now caught and re-raised as a RuntimeError with actionable guidance. Made-with: Cursor
a2dc93d to
a986306
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1617
Summary
ManagedMemoryResource()(no options) callscuMemGetMemPoolto retrieve the default managed memory pool, but on platforms without concurrent managed access (e.g. WSL2), this fails with a crypticCUDA_ERROR_NOT_SUPPORTED. Meanwhile, explicitly creating a pool viaManagedMemoryResource(options=ManagedMemoryResourceOptions(...))works fine on the same platform.This PR catches the error and re-raises it as a
RuntimeErrorwith an actionable message pointing users to the explicit options path. The improved message is only emitted when concurrent managed access is confirmed to be unavailable; otherwise the originalCUDAErrorpropagates unchanged.The error is identified via string match on the
CUDAErrormessage rather than inspecting a structured error code because (1) we prefer not to change theCUDAErrorclass or theMP_init_current_poolAPI for this, and (2) this is not a hot path.Changes
_managed_memory_resource.pyx— catchCUDAErrorfromMP_init_current_poolin theopts is Nonepath; checkconcurrent_managed_accessvia device properties and raise a clearRuntimeErrorwhen applicable_memory_pool.pyx— improve the CUDA < 13 fallback error message inMP_init_current_poolto describe the unsupported operationtest_managed_memory_warning.py— addtest_default_pool_error_without_concurrent_accessusing the existingdevice_without_concurrent_managed_accessfixtureTest Plan
concurrent_managed_access=False)Made with Cursor