Skip to content

Conversation

@kkraus14
Copy link
Contributor

This PR adds important deadlock warnings to the docstrings of Stream.add_callback and Stream.async_done methods.

Changes Made

  • Added warning about potential deadlock when using libraries that call CUDA functions without releasing the GIL
  • This can occur when callback functions attempt to acquire the GIL while another thread is holding it and making CUDA calls
  • Recommends using libraries that properly release the GIL around CUDA operations

Context

Based on the third bullet point from #317 (comment), these methods need clearer documentation about potential deadlock scenarios when integrating with other CUDA libraries that don't properly handle GIL management.

The warnings help developers understand the threading implications and make informed decisions about their code architecture to avoid deadlocks.


This pull request was generated from Cursor

…cstrings

- Add warning about potential deadlock when using libraries that call CUDA functions without releasing the GIL
- This can occur when callback functions attempt to acquire the GIL while another thread is holding it and making CUDA calls
- Recommends using libraries that properly release the GIL around CUDA operations
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jul 16, 2025

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

kkraus14 added 2 commits July 16, 2025 10:40
- Clarify that deadlock is due to lock ordering issue between GIL and CUDA driver lock
- Remove reference to 'another thread attempting to make CUDA calls' as this is not required
- Focus on the core issue: callback acquiring GIL while CUDA driver lock is held
@gmarkall
Copy link
Contributor

/ok to test

@gmarkall gmarkall added the 3 - Ready for Review Ready for review by team label Jul 18, 2025
@gmarkall gmarkall added 5 - Ready to merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team labels Jul 18, 2025
@gmarkall gmarkall merged commit 43184d7 into NVIDIA:main Jul 18, 2025
249 of 273 checks passed
gmarkall added a commit to gmarkall/numba-cuda that referenced this pull request Jul 18, 2025
- Add deadlock warnings to Stream.add_callback and Stream.async_done docstrings (NVIDIA#321)
- `MemoryPointer`: ensure `CUdeviceptr` used with NVIDIA binding (NVIDIA#328)
- Fix indexing GPUs with CUdevice object (NVIDIA#319)
- Fix bindings: consistency of contexts, streams, and events, similar to NVIDIA#295 (NVIDIA#296)
- Fix nvrtc resolution when CUDA_HOME env is set (NVIDIA#314)
@gmarkall gmarkall mentioned this pull request Jul 18, 2025
gmarkall added a commit that referenced this pull request Jul 18, 2025
- Add deadlock warnings to Stream.add_callback and Stream.async_done docstrings (#321)
- `MemoryPointer`: ensure `CUdeviceptr` used with NVIDIA binding (#328)
- Fix indexing GPUs with CUdevice object (#319)
- Fix bindings: consistency of contexts, streams, and events, similar to #295 (#296)
- Fix nvrtc resolution when CUDA_HOME env is set (#314)
atmnp pushed a commit to atmnp/numba-cuda that referenced this pull request Jul 21, 2025
…cstrings (NVIDIA#321)

* Add deadlock warnings to Stream.add_callback and Stream.async_done docstrings

- Add warning about potential deadlock when using libraries that call CUDA functions without releasing the GIL
- This can occur when callback functions attempt to acquire the GIL while another thread is holding it and making CUDA calls
- Recommends using libraries that properly release the GIL around CUDA operations

* Update docstring warnings to clarify lock ordering issue

- Clarify that deadlock is due to lock ordering issue between GIL and CUDA driver lock
- Remove reference to 'another thread attempting to make CUDA calls' as this is not required
- Focus on the core issue: callback acquiring GIL while CUDA driver lock is held
atmnp pushed a commit to atmnp/numba-cuda that referenced this pull request Jul 21, 2025
- Add deadlock warnings to Stream.add_callback and Stream.async_done docstrings (NVIDIA#321)
- `MemoryPointer`: ensure `CUdeviceptr` used with NVIDIA binding (NVIDIA#328)
- Fix indexing GPUs with CUdevice object (NVIDIA#319)
- Fix bindings: consistency of contexts, streams, and events, similar to NVIDIA#295 (NVIDIA#296)
- Fix nvrtc resolution when CUDA_HOME env is set (NVIDIA#314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Testing and reviews complete, ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants