File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
cuda_bindings/cuda/bindings/_path_finder Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ # Copyright 2025 NVIDIA Corporation. All rights reserved.
2+ # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3+
4+ import functools
5+ import glob
6+ import os
7+
8+ from cuda .bindings ._path_finder .find_sub_dirs import find_sub_dirs_all_sitepackages
9+ from cuda .bindings ._path_finder .supported_libs import IS_WINDOWS
10+
11+
12+ @functools .cache
13+ def find_nvidia_header_directory (libname : str ) -> str :
14+ assert libname == "nvshmem"
15+ assert not IS_WINDOWS
16+
17+ # Installed from a wheel
18+ nvidia_sub_dirs = ("nvidia" , "nvshmem" , "include" )
19+ for hdr_dir in find_sub_dirs_all_sitepackages (nvidia_sub_dirs ):
20+ nvshmem_h_path = os .path .join (hdr_dir , "nvshmem.h" )
21+ if os .path .isfile (nvshmem_h_path ):
22+ return hdr_dir
23+
24+ conda_prefix = os .environ .get ("CONDA_PREFIX" )
25+ if conda_prefix and os .path .isdir (conda_prefix ):
26+ hdr_dir = os .path .join (conda_prefix , "include" )
27+ if os .path .isdir (hdr_dir ):
28+ nvshmem_h_path = os .path .join (hdr_dir , "nvshmem.h" )
29+ if os .path .isfile (nvshmem_h_path ):
30+ return hdr_dir
31+
32+ for hdr_dir in sorted (glob .glob ("/usr/include/nvshmem_*" )):
33+ if os .path .isdir (hdr_dir ):
34+ nvshmem_h_path = os .path .join (hdr_dir , "nvshmem.h" )
35+ if os .path .isfile (nvshmem_h_path ):
36+ return hdr_dir
37+
38+ return None
You can’t perform that action at this time.
0 commit comments