[main] Only configure RMM allocators when running the CLI - #72
Open
Tobiaspk wants to merge 4 commits into
Open
Conversation
Move allocator setup out of an unconditional import-time side effect in __init__.py into configure_memory(), called only from cli/main.py, with an env-var and already-initialized guard.
Collaborator
Author
|
Found that "free_mem_str" crashes essentially if allocators are not set. Implementing a fix for this... |
Avoids an AttributeError when configure_memory() was never called (e.g. plain 'import segger' outside the CLI).
rmm.is_initialized() is True the instant rmm is imported (its default unpooled resource counts as initialized), so the guard was silently skipping pool/managed-memory setup any time another RAPIDS library (e.g. cuspa, cudf) imported rmm first -- which is effectively always. Check cp's actual allocator instead, since it's set together with torch's in this function.
Makes it observable why the RMM pool/managed-memory config wasn't applied (env override vs. already-active pool), instead of silently returning.
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.
Moves RMM/CuPy/PyTorch allocator setup out of an unconditional import-time side effect into a guarded
configure_memory()call invoked only from the CLI entry point.Set
export SEGGER_SKIP_ALLOCATOR_INIT=1to skip setting memory allocators.Closes #71
Here's how to import segger interactively now: