Skip to content

Commit 917803e

Browse files
committed
Add issue 1011 notes to the load_nvidia_dynamic_lib() docstring and the 1.3.0 release notes.
1 parent 3e7ca0e commit 917803e

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_nvidia_dynamic_lib.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ def load_nvidia_dynamic_lib(libname: str) -> LoadedDL:
6262
Returns:
6363
LoadedDL: Object containing the OS library handle and absolute path.
6464
65+
**Important:**
66+
67+
**Never close the returned handle.** Do **not** call ``dlclose`` (Linux) or
68+
``FreeLibrary`` (Windows) on the ``LoadedDL._handle_uint``.
69+
70+
**Why:** the return value is cached (``functools.cache``) and shared across the
71+
process. Closing the handle can unload the module while other code still uses
72+
it, leading to crashes or subtle failures.
73+
74+
This applies to Linux and Windows. For context, see issue #1011:
75+
https://github.com/NVIDIA/cuda-python/issues/1011
76+
6577
Raises:
6678
DynamicLibNotFoundError: If the library cannot be found or loaded.
6779
RuntimeError: If Python is not 64-bit.

cuda_pathfinder/docs/source/release/1.3.0-notes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88

99
Released on Sep 25, 2025
1010

11+
Important update to the ``load_nvidia_dynamic_lib`` documentation
12+
-----------------------------------------------------------------
13+
14+
The documentation for :func:`cuda.pathfinder.load_nvidia_dynamic_lib` now calls out
15+
an important behavior:
16+
17+
* **Do not close** the OS handle returned (``LoadedDL._handle_uint``). Avoid
18+
``dlclose`` (Linux) and ``FreeLibrary`` (Windows).
19+
20+
* **Reason:** the function's result is cached (``functools.cache``) and shared across
21+
the process. Closing the handle can unload the module while other code still holds
22+
a reference, which may cause crashes or latent errors.
23+
24+
This note is documentation‑only; there is no API change in 1.3.0. See issue #1011
25+
for background and discussion:
26+
https://github.com/NVIDIA/cuda-python/issues/1011
1127

1228
Highlights
1329
----------

0 commit comments

Comments
 (0)