Skip to content

Conversation

@Andy-Jost
Copy link
Contributor

@Andy-Jost Andy-Jost commented Feb 12, 2026

Summary

  • Emit a one-time UserWarning when ManagedMemoryResource is created on a platform where Device.properties.concurrent_managed_access is False. On such platforms, unsynchronized host access to managed memory causes a segfault.
  • Add tests for the warning (skip on platforms with concurrent access; pass on affected platforms like WSL2).
  • Unrelated: Skip test_build_hooks.py when setuptools is unavailable (Python 3.14+).

Closes #1607

Changes

  • cuda/core/_memory/_managed_memory_resource.pyx: Add _check_concurrent_managed_access helper with double-checked locking (warn-once pattern), and reset_concurrent_access_warning() for testing.
  • tests/test_managed_memory_warning.py: New test file verifying the warning fires and only fires once.
  • tests/test_build_hooks.py: Add pytest.importorskip("setuptools").

Test Coverage

  • test_warning_emitted: Verifies the warning content (category, message text).
  • test_warning_emitted_only_once: Verifies warn-once behavior across multiple resource creations.
  • Both tests validated on WSL2 (RTX 3500 Ada, concurrent_managed_access=False).

Made with Cursor

… access

Platforms where Device.properties.concurrent_managed_access is False
silently allow managed memory allocation but segfault on unsynchronized
host access. Emit a one-time UserWarning at construction time so users
get actionable guidance before hitting a crash.

Also skip test_build_hooks.py when setuptools is unavailable (Python 3.14+).

Closes NVIDIA#1607

Co-authored-by: Cursor <cursoragent@cursor.com>
@Andy-Jost Andy-Jost added this to the cuda.core v0.6.0 milestone Feb 12, 2026
@Andy-Jost Andy-Jost added bug Something isn't working cuda.core Everything related to the cuda.core module labels Feb 12, 2026
@Andy-Jost Andy-Jost self-assigned this Feb 12, 2026
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Feb 12, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Andy-Jost
Copy link
Contributor Author

/ok to test f7eeec8

@github-actions
Copy link

"allocation is forbidden while any GPU kernel is in flight, even "
"if the kernel does not touch that allocation. Failing to "
"synchronize before host access will cause a segfault. "
"See: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#um-coherency-hd",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn when creating ManagedMemoryResource on platforms without concurrent managed access

2 participants