numba-cuda 0.0.1__py3-none-any.whl → 0.0.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- _numba_cuda_redirector.pth +1 -0
- _numba_cuda_redirector.py +74 -0
- numba_cuda/VERSION +1 -0
- numba_cuda/__init__.py +5 -0
- numba_cuda/_version.py +19 -0
- numba_cuda/numba/cuda/__init__.py +22 -0
- numba_cuda/numba/cuda/api.py +526 -0
- numba_cuda/numba/cuda/api_util.py +30 -0
- numba_cuda/numba/cuda/args.py +77 -0
- numba_cuda/numba/cuda/cg.py +62 -0
- numba_cuda/numba/cuda/codegen.py +378 -0
- numba_cuda/numba/cuda/compiler.py +422 -0
- numba_cuda/numba/cuda/cpp_function_wrappers.cu +47 -0
- numba_cuda/numba/cuda/cuda_fp16.h +3631 -0
- numba_cuda/numba/cuda/cuda_fp16.hpp +2465 -0
- numba_cuda/numba/cuda/cuda_paths.py +258 -0
- numba_cuda/numba/cuda/cudadecl.py +806 -0
- numba_cuda/numba/cuda/cudadrv/__init__.py +9 -0
- numba_cuda/numba/cuda/cudadrv/devicearray.py +904 -0
- numba_cuda/numba/cuda/cudadrv/devices.py +248 -0
- numba_cuda/numba/cuda/cudadrv/driver.py +3201 -0
- numba_cuda/numba/cuda/cudadrv/drvapi.py +398 -0
- numba_cuda/numba/cuda/cudadrv/dummyarray.py +452 -0
- numba_cuda/numba/cuda/cudadrv/enums.py +607 -0
- numba_cuda/numba/cuda/cudadrv/error.py +36 -0
- numba_cuda/numba/cuda/cudadrv/libs.py +176 -0
- numba_cuda/numba/cuda/cudadrv/ndarray.py +20 -0
- numba_cuda/numba/cuda/cudadrv/nvrtc.py +260 -0
- numba_cuda/numba/cuda/cudadrv/nvvm.py +707 -0
- numba_cuda/numba/cuda/cudadrv/rtapi.py +10 -0
- numba_cuda/numba/cuda/cudadrv/runtime.py +142 -0
- numba_cuda/numba/cuda/cudaimpl.py +1055 -0
- numba_cuda/numba/cuda/cudamath.py +140 -0
- numba_cuda/numba/cuda/decorators.py +189 -0
- numba_cuda/numba/cuda/descriptor.py +33 -0
- numba_cuda/numba/cuda/device_init.py +89 -0
- numba_cuda/numba/cuda/deviceufunc.py +908 -0
- numba_cuda/numba/cuda/dispatcher.py +1057 -0
- numba_cuda/numba/cuda/errors.py +59 -0
- numba_cuda/numba/cuda/extending.py +7 -0
- numba_cuda/numba/cuda/initialize.py +13 -0
- numba_cuda/numba/cuda/intrinsic_wrapper.py +77 -0
- numba_cuda/numba/cuda/intrinsics.py +198 -0
- numba_cuda/numba/cuda/kernels/__init__.py +0 -0
- numba_cuda/numba/cuda/kernels/reduction.py +262 -0
- numba_cuda/numba/cuda/kernels/transpose.py +65 -0
- numba_cuda/numba/cuda/libdevice.py +3382 -0
- numba_cuda/numba/cuda/libdevicedecl.py +17 -0
- numba_cuda/numba/cuda/libdevicefuncs.py +1057 -0
- numba_cuda/numba/cuda/libdeviceimpl.py +83 -0
- numba_cuda/numba/cuda/mathimpl.py +448 -0
- numba_cuda/numba/cuda/models.py +48 -0
- numba_cuda/numba/cuda/nvvmutils.py +235 -0
- numba_cuda/numba/cuda/printimpl.py +86 -0
- numba_cuda/numba/cuda/random.py +292 -0
- numba_cuda/numba/cuda/simulator/__init__.py +38 -0
- numba_cuda/numba/cuda/simulator/api.py +110 -0
- numba_cuda/numba/cuda/simulator/compiler.py +9 -0
- numba_cuda/numba/cuda/simulator/cudadrv/__init__.py +2 -0
- numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +432 -0
- numba_cuda/numba/cuda/simulator/cudadrv/devices.py +117 -0
- numba_cuda/numba/cuda/simulator/cudadrv/driver.py +62 -0
- numba_cuda/numba/cuda/simulator/cudadrv/drvapi.py +4 -0
- numba_cuda/numba/cuda/simulator/cudadrv/dummyarray.py +4 -0
- numba_cuda/numba/cuda/simulator/cudadrv/error.py +6 -0
- numba_cuda/numba/cuda/simulator/cudadrv/libs.py +2 -0
- numba_cuda/numba/cuda/simulator/cudadrv/nvvm.py +29 -0
- numba_cuda/numba/cuda/simulator/cudadrv/runtime.py +19 -0
- numba_cuda/numba/cuda/simulator/kernel.py +308 -0
- numba_cuda/numba/cuda/simulator/kernelapi.py +495 -0
- numba_cuda/numba/cuda/simulator/reduction.py +15 -0
- numba_cuda/numba/cuda/simulator/vector_types.py +58 -0
- numba_cuda/numba/cuda/simulator_init.py +17 -0
- numba_cuda/numba/cuda/stubs.py +902 -0
- numba_cuda/numba/cuda/target.py +440 -0
- numba_cuda/numba/cuda/testing.py +202 -0
- numba_cuda/numba/cuda/tests/__init__.py +58 -0
- numba_cuda/numba/cuda/tests/cudadrv/__init__.py +8 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_array_attr.py +145 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +145 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_array_slicing.py +375 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_auto_context.py +21 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +179 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +235 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_libraries.py +22 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +193 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_ndarray.py +547 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +249 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +81 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +192 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_events.py +38 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_host_alloc.py +65 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_init.py +139 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_inline_ptx.py +37 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py +12 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +317 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py +127 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_mvc.py +54 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py +199 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py +37 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py +20 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_ptds.py +149 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_reset_device.py +36 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_runtime.py +85 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_select_device.py +41 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_streams.py +122 -0
- numba_cuda/numba/cuda/tests/cudapy/__init__.py +8 -0
- numba_cuda/numba/cuda/tests/cudapy/cache_usecases.py +234 -0
- numba_cuda/numba/cuda/tests/cudapy/cache_with_cpu_usecases.py +41 -0
- numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +58 -0
- numba_cuda/numba/cuda/tests/cudapy/jitlink.ptx +30 -0
- numba_cuda/numba/cuda/tests/cudapy/recursion_usecases.py +100 -0
- numba_cuda/numba/cuda/tests/cudapy/test_alignment.py +42 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array.py +260 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_args.py +201 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_methods.py +35 -0
- numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1620 -0
- numba_cuda/numba/cuda/tests/cudapy/test_blackscholes.py +120 -0
- numba_cuda/numba/cuda/tests/cudapy/test_boolean.py +24 -0
- numba_cuda/numba/cuda/tests/cudapy/test_caching.py +545 -0
- numba_cuda/numba/cuda/tests/cudapy/test_casting.py +257 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cffi.py +33 -0
- numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +276 -0
- numba_cuda/numba/cuda/tests/cudapy/test_complex.py +296 -0
- numba_cuda/numba/cuda/tests/cudapy/test_complex_kernel.py +20 -0
- numba_cuda/numba/cuda/tests/cudapy/test_const_string.py +129 -0
- numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +176 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +147 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py +435 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py +90 -0
- numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +94 -0
- numba_cuda/numba/cuda/tests/cudapy/test_debug.py +101 -0
- numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +221 -0
- numba_cuda/numba/cuda/tests/cudapy/test_device_func.py +222 -0
- numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +700 -0
- numba_cuda/numba/cuda/tests/cudapy/test_enums.py +121 -0
- numba_cuda/numba/cuda/tests/cudapy/test_errors.py +79 -0
- numba_cuda/numba/cuda/tests/cudapy/test_exception.py +174 -0
- numba_cuda/numba/cuda/tests/cudapy/test_extending.py +155 -0
- numba_cuda/numba/cuda/tests/cudapy/test_fastmath.py +244 -0
- numba_cuda/numba/cuda/tests/cudapy/test_forall.py +52 -0
- numba_cuda/numba/cuda/tests/cudapy/test_freevar.py +29 -0
- numba_cuda/numba/cuda/tests/cudapy/test_frexp_ldexp.py +66 -0
- numba_cuda/numba/cuda/tests/cudapy/test_globals.py +60 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc.py +456 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scalar.py +159 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scheduling.py +95 -0
- numba_cuda/numba/cuda/tests/cudapy/test_idiv.py +37 -0
- numba_cuda/numba/cuda/tests/cudapy/test_inspect.py +165 -0
- numba_cuda/numba/cuda/tests/cudapy/test_intrinsics.py +1106 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ipc.py +318 -0
- numba_cuda/numba/cuda/tests/cudapy/test_iterators.py +99 -0
- numba_cuda/numba/cuda/tests/cudapy/test_lang.py +64 -0
- numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +119 -0
- numba_cuda/numba/cuda/tests/cudapy/test_libdevice.py +187 -0
- numba_cuda/numba/cuda/tests/cudapy/test_lineinfo.py +199 -0
- numba_cuda/numba/cuda/tests/cudapy/test_localmem.py +164 -0
- numba_cuda/numba/cuda/tests/cudapy/test_mandel.py +37 -0
- numba_cuda/numba/cuda/tests/cudapy/test_math.py +786 -0
- numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +74 -0
- numba_cuda/numba/cuda/tests/cudapy/test_minmax.py +113 -0
- numba_cuda/numba/cuda/tests/cudapy/test_montecarlo.py +22 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multigpu.py +140 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multiprocessing.py +46 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multithreads.py +101 -0
- numba_cuda/numba/cuda/tests/cudapy/test_nondet.py +49 -0
- numba_cuda/numba/cuda/tests/cudapy/test_operator.py +401 -0
- numba_cuda/numba/cuda/tests/cudapy/test_optimization.py +86 -0
- numba_cuda/numba/cuda/tests/cudapy/test_overload.py +335 -0
- numba_cuda/numba/cuda/tests/cudapy/test_powi.py +124 -0
- numba_cuda/numba/cuda/tests/cudapy/test_print.py +128 -0
- numba_cuda/numba/cuda/tests/cudapy/test_py2_div_issue.py +33 -0
- numba_cuda/numba/cuda/tests/cudapy/test_random.py +104 -0
- numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +610 -0
- numba_cuda/numba/cuda/tests/cudapy/test_recursion.py +125 -0
- numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +76 -0
- numba_cuda/numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py +83 -0
- numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +85 -0
- numba_cuda/numba/cuda/tests/cudapy/test_slicing.py +37 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sm.py +444 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sm_creation.py +205 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sync.py +271 -0
- numba_cuda/numba/cuda/tests/cudapy/test_transpose.py +80 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +277 -0
- numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +47 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +307 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize.py +283 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_complex.py +20 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +69 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_device.py +36 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py +37 -0
- numba_cuda/numba/cuda/tests/cudapy/test_warning.py +139 -0
- numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +276 -0
- numba_cuda/numba/cuda/tests/cudasim/__init__.py +6 -0
- numba_cuda/numba/cuda/tests/cudasim/support.py +6 -0
- numba_cuda/numba/cuda/tests/cudasim/test_cudasim_issues.py +102 -0
- numba_cuda/numba/cuda/tests/data/__init__.py +0 -0
- numba_cuda/numba/cuda/tests/data/cuda_include.cu +5 -0
- numba_cuda/numba/cuda/tests/data/error.cu +7 -0
- numba_cuda/numba/cuda/tests/data/jitlink.cu +23 -0
- numba_cuda/numba/cuda/tests/data/jitlink.ptx +51 -0
- numba_cuda/numba/cuda/tests/data/warn.cu +7 -0
- numba_cuda/numba/cuda/tests/doc_examples/__init__.py +6 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/__init__.py +0 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/functions.cu +49 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +77 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py +76 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +82 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +155 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_matmul.py +173 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_montecarlo.py +109 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_random.py +59 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_reduction.py +76 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +130 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_ufunc.py +50 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_vecadd.py +73 -0
- numba_cuda/numba/cuda/tests/nocuda/__init__.py +8 -0
- numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +359 -0
- numba_cuda/numba/cuda/tests/nocuda/test_function_resolution.py +36 -0
- numba_cuda/numba/cuda/tests/nocuda/test_import.py +49 -0
- numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +238 -0
- numba_cuda/numba/cuda/tests/nocuda/test_nvvm.py +54 -0
- numba_cuda/numba/cuda/types.py +37 -0
- numba_cuda/numba/cuda/ufuncs.py +662 -0
- numba_cuda/numba/cuda/vector_types.py +209 -0
- numba_cuda/numba/cuda/vectorizers.py +252 -0
- numba_cuda-0.0.13.dist-info/LICENSE +25 -0
- numba_cuda-0.0.13.dist-info/METADATA +69 -0
- numba_cuda-0.0.13.dist-info/RECORD +231 -0
- {numba_cuda-0.0.1.dist-info → numba_cuda-0.0.13.dist-info}/WHEEL +1 -1
- numba_cuda-0.0.1.dist-info/METADATA +0 -10
- numba_cuda-0.0.1.dist-info/RECORD +0 -5
- {numba_cuda-0.0.1.dist-info → numba_cuda-0.0.13.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,258 @@
|
|
1
|
+
import sys
|
2
|
+
import re
|
3
|
+
import os
|
4
|
+
from collections import namedtuple
|
5
|
+
|
6
|
+
from numba.core.config import IS_WIN32
|
7
|
+
from numba.misc.findlib import find_lib, find_file
|
8
|
+
|
9
|
+
|
10
|
+
_env_path_tuple = namedtuple('_env_path_tuple', ['by', 'info'])
|
11
|
+
|
12
|
+
|
13
|
+
def _find_valid_path(options):
|
14
|
+
"""Find valid path from *options*, which is a list of 2-tuple of
|
15
|
+
(name, path). Return first pair where *path* is not None.
|
16
|
+
If no valid path is found, return ('<unknown>', None)
|
17
|
+
"""
|
18
|
+
for by, data in options:
|
19
|
+
if data is not None:
|
20
|
+
return by, data
|
21
|
+
else:
|
22
|
+
return '<unknown>', None
|
23
|
+
|
24
|
+
|
25
|
+
def _get_libdevice_path_decision():
|
26
|
+
options = [
|
27
|
+
('Conda environment', get_conda_ctk()),
|
28
|
+
('Conda environment (NVIDIA package)', get_nvidia_libdevice_ctk()),
|
29
|
+
('CUDA_HOME', get_cuda_home('nvvm', 'libdevice')),
|
30
|
+
('System', get_system_ctk('nvvm', 'libdevice')),
|
31
|
+
('Debian package', get_debian_pkg_libdevice()),
|
32
|
+
]
|
33
|
+
by, libdir = _find_valid_path(options)
|
34
|
+
return by, libdir
|
35
|
+
|
36
|
+
|
37
|
+
def _nvvm_lib_dir():
|
38
|
+
if IS_WIN32:
|
39
|
+
return 'nvvm', 'bin'
|
40
|
+
else:
|
41
|
+
return 'nvvm', 'lib64'
|
42
|
+
|
43
|
+
|
44
|
+
def _get_nvvm_path_decision():
|
45
|
+
options = [
|
46
|
+
('Conda environment', get_conda_ctk()),
|
47
|
+
('Conda environment (NVIDIA package)', get_nvidia_nvvm_ctk()),
|
48
|
+
('CUDA_HOME', get_cuda_home(*_nvvm_lib_dir())),
|
49
|
+
('System', get_system_ctk(*_nvvm_lib_dir())),
|
50
|
+
]
|
51
|
+
by, path = _find_valid_path(options)
|
52
|
+
return by, path
|
53
|
+
|
54
|
+
|
55
|
+
def _get_libdevice_paths():
|
56
|
+
by, libdir = _get_libdevice_path_decision()
|
57
|
+
# Search for pattern
|
58
|
+
pat = r'libdevice(\.\d+)*\.bc$'
|
59
|
+
candidates = find_file(re.compile(pat), libdir)
|
60
|
+
# Keep only the max (most recent version) of the bitcode files.
|
61
|
+
out = max(candidates, default=None)
|
62
|
+
return _env_path_tuple(by, out)
|
63
|
+
|
64
|
+
|
65
|
+
def _cudalib_path():
|
66
|
+
if IS_WIN32:
|
67
|
+
return 'bin'
|
68
|
+
else:
|
69
|
+
return 'lib64'
|
70
|
+
|
71
|
+
|
72
|
+
def _cuda_home_static_cudalib_path():
|
73
|
+
if IS_WIN32:
|
74
|
+
return ('lib', 'x64')
|
75
|
+
else:
|
76
|
+
return ('lib64',)
|
77
|
+
|
78
|
+
|
79
|
+
def _get_cudalib_dir_path_decision():
|
80
|
+
options = [
|
81
|
+
('Conda environment', get_conda_ctk()),
|
82
|
+
('Conda environment (NVIDIA package)', get_nvidia_cudalib_ctk()),
|
83
|
+
('CUDA_HOME', get_cuda_home(_cudalib_path())),
|
84
|
+
('System', get_system_ctk(_cudalib_path())),
|
85
|
+
]
|
86
|
+
by, libdir = _find_valid_path(options)
|
87
|
+
return by, libdir
|
88
|
+
|
89
|
+
|
90
|
+
def _get_static_cudalib_dir_path_decision():
|
91
|
+
options = [
|
92
|
+
('Conda environment', get_conda_ctk()),
|
93
|
+
('Conda environment (NVIDIA package)', get_nvidia_static_cudalib_ctk()),
|
94
|
+
('CUDA_HOME', get_cuda_home(*_cuda_home_static_cudalib_path())),
|
95
|
+
('System', get_system_ctk(_cudalib_path())),
|
96
|
+
]
|
97
|
+
by, libdir = _find_valid_path(options)
|
98
|
+
return by, libdir
|
99
|
+
|
100
|
+
|
101
|
+
def _get_cudalib_dir():
|
102
|
+
by, libdir = _get_cudalib_dir_path_decision()
|
103
|
+
return _env_path_tuple(by, libdir)
|
104
|
+
|
105
|
+
|
106
|
+
def _get_static_cudalib_dir():
|
107
|
+
by, libdir = _get_static_cudalib_dir_path_decision()
|
108
|
+
return _env_path_tuple(by, libdir)
|
109
|
+
|
110
|
+
|
111
|
+
def get_system_ctk(*subdirs):
|
112
|
+
"""Return path to system-wide cudatoolkit; or, None if it doesn't exist.
|
113
|
+
"""
|
114
|
+
# Linux?
|
115
|
+
if sys.platform.startswith('linux'):
|
116
|
+
# Is cuda alias to /usr/local/cuda?
|
117
|
+
# We are intentionally not getting versioned cuda installation.
|
118
|
+
base = '/usr/local/cuda'
|
119
|
+
if os.path.exists(base):
|
120
|
+
return os.path.join(base, *subdirs)
|
121
|
+
|
122
|
+
|
123
|
+
def get_conda_ctk():
|
124
|
+
"""Return path to directory containing the shared libraries of cudatoolkit.
|
125
|
+
"""
|
126
|
+
is_conda_env = os.path.exists(os.path.join(sys.prefix, 'conda-meta'))
|
127
|
+
if not is_conda_env:
|
128
|
+
return
|
129
|
+
# Assume the existence of NVVM to imply cudatoolkit installed
|
130
|
+
paths = find_lib('nvvm')
|
131
|
+
if not paths:
|
132
|
+
return
|
133
|
+
# Use the directory name of the max path
|
134
|
+
return os.path.dirname(max(paths))
|
135
|
+
|
136
|
+
|
137
|
+
def get_nvidia_nvvm_ctk():
|
138
|
+
"""Return path to directory containing the NVVM shared library.
|
139
|
+
"""
|
140
|
+
is_conda_env = os.path.exists(os.path.join(sys.prefix, 'conda-meta'))
|
141
|
+
if not is_conda_env:
|
142
|
+
return
|
143
|
+
|
144
|
+
# Assume the existence of NVVM in the conda env implies that a CUDA toolkit
|
145
|
+
# conda package is installed.
|
146
|
+
|
147
|
+
# First, try the location used on Linux and the Windows 11.x packages
|
148
|
+
libdir = os.path.join(sys.prefix, 'nvvm', _cudalib_path())
|
149
|
+
if not os.path.exists(libdir) or not os.path.isdir(libdir):
|
150
|
+
# If that fails, try the location used for Windows 12.x packages
|
151
|
+
libdir = os.path.join(sys.prefix, 'Library', 'nvvm', _cudalib_path())
|
152
|
+
if not os.path.exists(libdir) or not os.path.isdir(libdir):
|
153
|
+
# If that doesn't exist either, assume we don't have the NVIDIA
|
154
|
+
# conda package
|
155
|
+
return
|
156
|
+
|
157
|
+
paths = find_lib('nvvm', libdir=libdir)
|
158
|
+
if not paths:
|
159
|
+
return
|
160
|
+
# Use the directory name of the max path
|
161
|
+
return os.path.dirname(max(paths))
|
162
|
+
|
163
|
+
|
164
|
+
def get_nvidia_libdevice_ctk():
|
165
|
+
"""Return path to directory containing the libdevice library.
|
166
|
+
"""
|
167
|
+
nvvm_ctk = get_nvidia_nvvm_ctk()
|
168
|
+
if not nvvm_ctk:
|
169
|
+
return
|
170
|
+
nvvm_dir = os.path.dirname(nvvm_ctk)
|
171
|
+
return os.path.join(nvvm_dir, 'libdevice')
|
172
|
+
|
173
|
+
|
174
|
+
def get_nvidia_cudalib_ctk():
|
175
|
+
"""Return path to directory containing the shared libraries of cudatoolkit.
|
176
|
+
"""
|
177
|
+
nvvm_ctk = get_nvidia_nvvm_ctk()
|
178
|
+
if not nvvm_ctk:
|
179
|
+
return
|
180
|
+
env_dir = os.path.dirname(os.path.dirname(nvvm_ctk))
|
181
|
+
subdir = 'bin' if IS_WIN32 else 'lib'
|
182
|
+
return os.path.join(env_dir, subdir)
|
183
|
+
|
184
|
+
|
185
|
+
def get_nvidia_static_cudalib_ctk():
|
186
|
+
"""Return path to directory containing the static libraries of cudatoolkit.
|
187
|
+
"""
|
188
|
+
nvvm_ctk = get_nvidia_nvvm_ctk()
|
189
|
+
if not nvvm_ctk:
|
190
|
+
return
|
191
|
+
|
192
|
+
if IS_WIN32 and ("Library" not in nvvm_ctk):
|
193
|
+
# Location specific to CUDA 11.x packages on Windows
|
194
|
+
dirs = ('Lib', 'x64')
|
195
|
+
else:
|
196
|
+
# Linux, or Windows with CUDA 12.x packages
|
197
|
+
dirs = ('lib',)
|
198
|
+
|
199
|
+
env_dir = os.path.dirname(os.path.dirname(nvvm_ctk))
|
200
|
+
return os.path.join(env_dir, *dirs)
|
201
|
+
|
202
|
+
|
203
|
+
def get_cuda_home(*subdirs):
|
204
|
+
"""Get paths of CUDA_HOME.
|
205
|
+
If *subdirs* are the subdirectory name to be appended in the resulting
|
206
|
+
path.
|
207
|
+
"""
|
208
|
+
cuda_home = os.environ.get('CUDA_HOME')
|
209
|
+
if cuda_home is None:
|
210
|
+
# Try Windows CUDA installation without Anaconda
|
211
|
+
cuda_home = os.environ.get('CUDA_PATH')
|
212
|
+
if cuda_home is not None:
|
213
|
+
return os.path.join(cuda_home, *subdirs)
|
214
|
+
|
215
|
+
|
216
|
+
def _get_nvvm_path():
|
217
|
+
by, path = _get_nvvm_path_decision()
|
218
|
+
candidates = find_lib('nvvm', path)
|
219
|
+
path = max(candidates) if candidates else None
|
220
|
+
return _env_path_tuple(by, path)
|
221
|
+
|
222
|
+
|
223
|
+
def get_cuda_paths():
|
224
|
+
"""Returns a dictionary mapping component names to a 2-tuple
|
225
|
+
of (source_variable, info).
|
226
|
+
|
227
|
+
The returned dictionary will have the following keys and infos:
|
228
|
+
- "nvvm": file_path
|
229
|
+
- "libdevice": List[Tuple[arch, file_path]]
|
230
|
+
- "cudalib_dir": directory_path
|
231
|
+
|
232
|
+
Note: The result of the function is cached.
|
233
|
+
"""
|
234
|
+
# Check cache
|
235
|
+
if hasattr(get_cuda_paths, '_cached_result'):
|
236
|
+
return get_cuda_paths._cached_result
|
237
|
+
else:
|
238
|
+
# Not in cache
|
239
|
+
d = {
|
240
|
+
'nvvm': _get_nvvm_path(),
|
241
|
+
'libdevice': _get_libdevice_paths(),
|
242
|
+
'cudalib_dir': _get_cudalib_dir(),
|
243
|
+
'static_cudalib_dir': _get_static_cudalib_dir(),
|
244
|
+
}
|
245
|
+
# Cache result
|
246
|
+
get_cuda_paths._cached_result = d
|
247
|
+
return d
|
248
|
+
|
249
|
+
|
250
|
+
def get_debian_pkg_libdevice():
|
251
|
+
"""
|
252
|
+
Return the Debian NVIDIA Maintainers-packaged libdevice location, if it
|
253
|
+
exists.
|
254
|
+
"""
|
255
|
+
pkg_libdevice_location = '/usr/lib/nvidia-cuda-toolkit/libdevice'
|
256
|
+
if not os.path.exists(pkg_libdevice_location):
|
257
|
+
return None
|
258
|
+
return pkg_libdevice_location
|