Skip to content

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Sep 20, 2025

Add a Conda-specific search into load_nvidia_dynamic_lib(). This makes the search more intuitive and predictable.

This PR is essentially two in one:

1. Production code changes:

2. Bug fix in test and related cleanup:


The production code changes are best understood by reviewing:

  • commit 8da27a7Update load_nvidia_dynamic_lib docstring

The changes are surgical, based on reusing existing logic for locating dynamic libraries under CUDA_HOME.

Currently CI testing does not include testing with Conda. The interesting parts of the outputs from additional manual local testing are below:


Piggy-backed:

Closes #1007

Copy link
Contributor

copy-pr-bot bot commented Sep 20, 2025

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

Contributors can view more details about this message here.

@rwgk rwgk force-pushed the load_nvidia_dynamic_lib_conda_specific branch from f1482bd to 5b3c5eb Compare September 22, 2025 00:37
@rwgk
Copy link
Collaborator Author

rwgk commented Sep 22, 2025

/ok to test

This comment has been minimized.

@rwgk
Copy link
Collaborator Author

rwgk commented Sep 22, 2025

/ok to test

@rwgk rwgk self-assigned this Sep 22, 2025
@rwgk rwgk added the cuda.pathfinder Everything related to the cuda.pathfinder module label Sep 22, 2025
self._find_using_lib_dir(cuda_home_lib_dir)

def _find_using_lib_dir(self, lib_dir: str) -> None:
if IS_WINDOWS:
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is pre-existing, but it seems like this is begging for some sort of interface that you can isolate into modules and then import at the top level based on platform, similar to how to the os and pathlib modules work. This would likely avoid a lot of in-method or in-function branching.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried this twice before but backed off both times after seeing where it's going, and determining it's a net loss in terms of code organization and readability.

In contrast, it was clearly a net win for the rest of the code underneath load_nvidia_dynamic_lib.py, which also started out as interleaved code.

if result.returncode != 0:
raise_child_process_failed()
assert not result.stderr
if result.stdout.startswith("CHILD_LOAD_NVIDIA_DYNAMIC_LIB_HELPER_DYNAMIC_LIB_NOT_FOUND_ERROR:"):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some reason not to use stderr here, since that is its intended use (communicating errors)?

Copy link
Collaborator Author

@rwgk rwgk Sep 22, 2025

Choose a reason for hiding this comment

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

That was a deliberate choice I made while working on commit edff6ec.

See the bug-fix commit right before (2642d35) for why I worked on it.

The requirements on my mind:

  • I didn't want to start fiddling with exit codes (result.returncode).

  • I wanted to make it so that a non-zero error code always leads to an exception.

  • I also wanted to get away from searching for substrings that are not guaranteed to be conclusive: "DynamicLibNotFoundError: Failure finding " in result.stderr

So I introduced a tag that is practically certain to be unique: CHILD_LOAD_NVIDIA_DYNAMIC_LIB_HELPER_DYNAMIC_LIB_NOT_FOUND_ERROR:, to be sent via stdout for the reasons above.

I added assert os.path.isfile(abs_path) # double-check the abs_path to be sure if I miss the tag somehow, it'll not slip through unnoticed.

2. **Conda environment**
- Conda installations are discovered via ``CONDA_PREFIX``, which is
predefined in activated conda environments (see
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
predefined in activated conda environments (see
defined in activated conda environments (see

I don't think the pre prefix is making a useful distinction beyond just "defined".

Copy link
Collaborator Author

@rwgk rwgk Sep 22, 2025

Choose a reason for hiding this comment

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

Changed to "defined automatically": commit bd5e2ae

This is for people not-so-familiar with Conda. That one extra word is to reassure them that they don't have to think about defining the variable themselves.

@rwgk
Copy link
Collaborator Author

rwgk commented Sep 22, 2025

Local testing: Linux, Conda, CTK13

conda create --yes -n ctk1301_py313 python=3.13 cuda-toolkit=13.0.1 conda-forge::cuda-cccl
CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS=all_must_work pytest -ra -s -v tests/
=========================================================== INFO summary ============================================================
INFO test_find_libname_nvshmem: hdr_dir='/usr/include/nvshmem_13'
INFO test_find_ctk_headers[cccl]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include/cccl'
INFO test_find_ctk_headers[cublas]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[cudart]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[cufft]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[curand]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[cusolver]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[cusparse]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[npp]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[nvcc]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[nvfatbin]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[nvjitlink]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[nvjpeg]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[nvrtc]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_find_ctk_headers[nvvm]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/nvvm/include'
INFO test_find_ctk_headers[cufile]: hdr_dir='/home/rgrossekunst/miniforge3/envs/ctk1301_py313/targets/x86_64-linux/include'
INFO test_load_nvidia_dynamic_lib[cudart]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcudart.so
INFO test_load_nvidia_dynamic_lib[nvfatbin]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnvfatbin.so
INFO test_load_nvidia_dynamic_lib[nvJitLink]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnvJitLink.so
INFO test_load_nvidia_dynamic_lib[nvrtc]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnvrtc.so
INFO test_load_nvidia_dynamic_lib[nvvm]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/nvvm/lib64/libnvvm.so
INFO test_load_nvidia_dynamic_lib[cublas]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcublas.so
INFO test_load_nvidia_dynamic_lib[cublasLt]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcublasLt.so
INFO test_load_nvidia_dynamic_lib[cufft]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcufft.so
INFO test_load_nvidia_dynamic_lib[cufftw]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcufftw.so
INFO test_load_nvidia_dynamic_lib[curand]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcurand.so
INFO test_load_nvidia_dynamic_lib[cusolver]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcusolver.so
INFO test_load_nvidia_dynamic_lib[cusolverMg]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcusolverMg.so
INFO test_load_nvidia_dynamic_lib[cusparse]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcusparse.so
INFO test_load_nvidia_dynamic_lib[nppc]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppc.so
INFO test_load_nvidia_dynamic_lib[nppial]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppial.so
INFO test_load_nvidia_dynamic_lib[nppicc]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppicc.so
INFO test_load_nvidia_dynamic_lib[nppidei]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppidei.so
INFO test_load_nvidia_dynamic_lib[nppif]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppif.so
INFO test_load_nvidia_dynamic_lib[nppig]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppig.so
INFO test_load_nvidia_dynamic_lib[nppim]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppim.so
INFO test_load_nvidia_dynamic_lib[nppist]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppist.so
INFO test_load_nvidia_dynamic_lib[nppisu]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppisu.so
INFO test_load_nvidia_dynamic_lib[nppitc]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnppitc.so
INFO test_load_nvidia_dynamic_lib[npps]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnpps.so
INFO test_load_nvidia_dynamic_lib[nvblas]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnvblas.so
INFO test_load_nvidia_dynamic_lib[nvjpeg]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libnvjpeg.so
INFO test_load_nvidia_dynamic_lib[cufile]: abs_path=/home/rgrossekunst/miniforge3/envs/ctk1301_py313/lib/libcufile.so
====================================================== short test summary info ======================================================
SKIPPED [1] tests/test_utils_env_vars.py:81: Windows-specific case-folding check
=================================================== 72 passed, 1 skipped in 3.95s ===================================================

@leofang leofang added enhancement Any code-related improvements P0 High priority - Must do! labels Sep 25, 2025
@leofang leofang added this to the cuda-pathfinder 1.3.0 milestone Sep 25, 2025
…o `_load_lib_no_cache()`. Rename `found` variable to `finder` to make the design change (de-centralizing the search order) more obvious.
@rwgk
Copy link
Collaborator Author

rwgk commented Sep 25, 2025

I cherry-picked the one extra commit from #1013 into this PR, so that we don't have the extra review and CI overhead just for that: commit 917803e

I also changed the 1.3.0 release date to Monday (it seemed to rushed for today, b/o timezones; avoid Fridays for releases): commit 37414a5

@rwgk
Copy link
Collaborator Author

rwgk commented Sep 25, 2025

I'm intentionally holding off re-running the tests, in case there are more requests for changes.

I retested locally with /usr/local/cuda CTK 13, site-packages CTK 12 & 13, Conda Windows & Linux x CTK 12 & 13. Therefore it seems very unlikely that CI testing will fail.

@rwgk
Copy link
Collaborator Author

rwgk commented Sep 25, 2025

I'll see if I can fix #1007 before triggering the CI here again.

…module:: cuda.pathfinder` in cuda_pathfinder/docs/source/release/*-notes.rst
…warning:

/home/rgrossekunst/forked/cuda-python/cuda_pathfinder/docs/source/contribute.rst:14: WARNING: Bullet list ends without a blank line; unexpected unindent. [docutils]
WARNING: html_static_path entry '_static' does not exist
@rwgk
Copy link
Collaborator Author

rwgk commented Sep 26, 2025

I'll see if I can fix #1007 before triggering the CI here again.

Done: 44ed3e6, 45fb2cd, d19d3ec

There are no more sphinx warnings for cuda_pathfinder.

@rwgk
Copy link
Collaborator Author

rwgk commented Sep 26, 2025

/ok to test

@leofang leofang enabled auto-merge (squash) September 26, 2025 01:42
@leofang leofang merged commit 5a6cbcd into NVIDIA:main Sep 26, 2025
70 checks passed
Copy link

Doc Preview CI
Preview removed because the pull request was closed or merged.

@rwgk rwgk deleted the load_nvidia_dynamic_lib_conda_specific branch September 26, 2025 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda.pathfinder Everything related to the cuda.pathfinder module enhancement Any code-related improvements P0 High priority - Must do!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Doc build generates lots of ignored exceptions
5 participants