Skip to content

[main] Only configure RMM allocators when running the CLI - #72

Open
Tobiaspk wants to merge 4 commits into
mainfrom
fix/cli-only-allocator-init
Open

[main] Only configure RMM allocators when running the CLI#72
Tobiaspk wants to merge 4 commits into
mainfrom
fix/cli-only-allocator-init

Conversation

@Tobiaspk

@Tobiaspk Tobiaspk commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

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=1 to skip setting memory allocators.

Closes #71

Here's how to import segger interactively now:

import segger
segger.configure_memory()

from segger.io.preprocessor import get_preprocessor
...

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.
@Tobiaspk Tobiaspk changed the title Only configure RMM allocators when running the CLI [main] Only configure RMM allocators when running the CLI Jul 21, 2026
@Tobiaspk
Tobiaspk requested a review from EliHei2 July 21, 2026 13:51
@Tobiaspk

Copy link
Copy Markdown
Collaborator Author

Found that "free_mem_str" crashes essentially if allocators are not set. Implementing a fix for this...

Krause and others added 3 commits July 21, 2026 10:06
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.
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.

[main] Stop setting memory allocators at segger import.

1 participant