Something went wrong. Try again.
Nix Packages collection & NixOS github.com/NixOS/nixpkgs
Something went wrong. Try again.
9.7 kB · 231 lines
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232diff --git a/cuda_bindings/cuda/bindings/_internal/cudla_linux.pyx b/cuda_bindings/cuda/bindings/_internal/cudla_linux.pyxindex b9cbb73a32e..e46890c24ec 100644--- a/cuda_bindings/cuda/bindings/_internal/cudla_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/cudla_linux.pyx@@ -61,7 +61,7 @@ cdef object _cyb_symbol_lock = _cyb_threading.Lock() from libc.stdint cimport uintptr_t from .utils import FunctionNotFoundError, NotSupportedError-from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL ###############################################################################@@ -248,7 +248,7 @@ cpdef _inspect_function_pointer(str name): cdef void* load_library() except* with gil:- cdef uintptr_t handle = load_nvidia_dynamic_lib("cudla")._handle_uint+ cdef uintptr_t handle = CDLL("@libcudla@")._handle return <void*>handle diff --git a/cuda_bindings/cuda/bindings/_internal/cufile_linux.pyx b/cuda_bindings/cuda/bindings/_internal/cufile_linux.pyxindex 03864ddd836..4e2a705a2ae 100644--- a/cuda_bindings/cuda/bindings/_internal/cufile_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/cufile_linux.pyx@@ -59,7 +59,7 @@ cdef object _cyb_symbol_lock = _cyb_threading.Lock() from libc.stdint cimport uintptr_t from .utils import FunctionNotFoundError, NotSupportedError-from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL ###############################################################################@@ -599,7 +599,7 @@ cpdef _inspect_function_pointer(str name): cdef void* load_library() except* with gil:- cdef uintptr_t handle = load_nvidia_dynamic_lib("cufile")._handle_uint+ cdef uintptr_t handle = CDLL("@libcufile@/lib/libcufile.so")._handle return <void*>handle diff --git a/cuda_bindings/cuda/bindings/_internal/driver_linux.pyx b/cuda_bindings/cuda/bindings/_internal/driver_linux.pyxindex 6fc1ca20c77..6090745eb4e 100644--- a/cuda_bindings/cuda/bindings/_internal/driver_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/driver_linux.pyx@@ -59,7 +59,7 @@ cdef object _cyb_symbol_lock = _cyb_threading.Lock() from libc.stdint cimport uintptr_t from .utils import FunctionNotFoundError, NotSupportedError-from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL ###############################################################################@@ -3785,7 +3785,13 @@ cpdef _inspect_function_pointer(str name): cdef void* load_library() except* with gil:- cdef uintptr_t handle = load_nvidia_dynamic_lib("cuda")._handle_uint+ # Search like the dynamic linker would for a library with the driver link in its RUNPATH: LD_LIBRARY_PATH+ # first (e.g. a host driver exposed by nixglhost or a container runtime), then the configured path.+ cdef uintptr_t handle+ try:+ handle = CDLL("libcuda.so.1")._handle+ except OSError:+ handle = CDLL("@libcuda@/libcuda.so.1")._handle return <void*>handle diff --git a/cuda_bindings/cuda/bindings/_internal/nvfatbin_linux.pyx b/cuda_bindings/cuda/bindings/_internal/nvfatbin_linux.pyxindex 937878b5a15..78815032dc6 100644--- a/cuda_bindings/cuda/bindings/_internal/nvfatbin_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/nvfatbin_linux.pyx@@ -57,7 +57,7 @@ cdef object _cyb_symbol_lock = _cyb_threading.Lock() from libc.stdint cimport uintptr_t from .utils import FunctionNotFoundError, NotSupportedError-from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL ###############################################################################@@ -233,7 +233,7 @@ cpdef _inspect_function_pointer(str name): cdef void* load_library() except* with gil:- cdef uintptr_t handle = load_nvidia_dynamic_lib("nvfatbin")._handle_uint+ cdef uintptr_t handle = CDLL("@libnvfatbin@/lib/libnvfatbin.so")._handle return <void*>handle diff --git a/cuda_bindings/cuda/bindings/_internal/nvjitlink_linux.pyx b/cuda_bindings/cuda/bindings/_internal/nvjitlink_linux.pyxindex 4c21693caf7..72e9b920802 100644--- a/cuda_bindings/cuda/bindings/_internal/nvjitlink_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/nvjitlink_linux.pyx@@ -60,7 +60,7 @@ cdef object _cyb_symbol_lock = _cyb_threading.Lock() from libc.stdint cimport uintptr_t from .utils import FunctionNotFoundError, NotSupportedError-from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL ###############################################################################@@ -280,7 +280,7 @@ cpdef _inspect_function_pointer(str name): cdef void* load_library() except* with gil:- cdef uintptr_t handle = load_nvidia_dynamic_lib("nvJitLink")._handle_uint+ cdef uintptr_t handle = CDLL("@libnvjitlink@/lib/libnvJitLink.so")._handle return <void*>handle diff --git a/cuda_bindings/cuda/bindings/_internal/nvml_linux.pyx b/cuda_bindings/cuda/bindings/_internal/nvml_linux.pyxindex ab251a57fe1..a5e95f1348f 100644--- a/cuda_bindings/cuda/bindings/_internal/nvml_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/nvml_linux.pyx@@ -57,7 +57,7 @@ cdef object _cyb_symbol_lock = _cyb_threading.Lock() from libc.stdint cimport uintptr_t from .utils import FunctionNotFoundError, NotSupportedError-from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL ###############################################################################@@ -4171,7 +4171,13 @@ cpdef _inspect_function_pointer(str name): cdef void* load_library() except* with gil:- cdef uintptr_t handle = load_nvidia_dynamic_lib("nvml")._handle_uint+ # Search like the dynamic linker would for a library with the driver link in its RUNPATH: LD_LIBRARY_PATH+ # first (e.g. a host driver exposed by nixglhost or a container runtime), then the configured path.+ cdef uintptr_t handle+ try:+ handle = CDLL("libnvidia-ml.so.1")._handle+ except OSError:+ handle = CDLL("@libnvml@/lib/libnvidia-ml.so")._handle return <void*>handle diff --git a/cuda_bindings/cuda/bindings/_internal/nvrtc_linux.pyx b/cuda_bindings/cuda/bindings/_internal/nvrtc_linux.pyxindex 861fc42e34b..c8ba57ce746 100644--- a/cuda_bindings/cuda/bindings/_internal/nvrtc_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/nvrtc_linux.pyx@@ -57,7 +57,7 @@ cdef object _cyb_symbol_lock = _cyb_threading.Lock() from libc.stdint cimport uintptr_t from .utils import FunctionNotFoundError, NotSupportedError-from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL ###############################################################################@@ -420,7 +420,7 @@ cpdef _inspect_function_pointer(str name): cdef void* load_library() except* with gil:- cdef uintptr_t handle = load_nvidia_dynamic_lib("nvrtc")._handle_uint+ cdef uintptr_t handle = CDLL("@libnvrtc@/lib/libnvrtc.so")._handle return <void*>handle diff --git a/cuda_bindings/cuda/bindings/_internal/nvvm_linux.pyx b/cuda_bindings/cuda/bindings/_internal/nvvm_linux.pyxindex 39329bc9b64..220577dbc4a 100644--- a/cuda_bindings/cuda/bindings/_internal/nvvm_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/nvvm_linux.pyx@@ -57,7 +57,7 @@ cdef object _cyb_symbol_lock = _cyb_threading.Lock() from libc.stdint cimport uintptr_t from .utils import FunctionNotFoundError, NotSupportedError-from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL ###############################################################################@@ -255,7 +255,7 @@ cpdef _inspect_function_pointer(str name): cdef void* load_library() except* with gil:- cdef uintptr_t handle = load_nvidia_dynamic_lib("nvvm")._handle_uint+ cdef uintptr_t handle = CDLL("@libnvvm@/lib/libnvvm.so")._handle return <void*>handle diff --git a/cuda_bindings/cuda/bindings/_internal/runtime_linux.pyx b/cuda_bindings/cuda/bindings/_internal/runtime_linux.pyxindex 1ae37127bd1..eb7b9054cf1 100644--- a/cuda_bindings/cuda/bindings/_internal/runtime_linux.pyx+++ b/cuda_bindings/cuda/bindings/_internal/runtime_linux.pyx@@ -9,11 +9,19 @@ import os from libc.stdint cimport uintptr_t -from cuda.pathfinder import load_nvidia_dynamic_lib+from ctypes import CDLL cimport cuda.bindings._lib.dlfcn as dlfcn cimport cuda.bindings._internal.runtime_ptds as ptds cimport cython +try:+ CDLL("libcuda.so.1")+except OSError:+ try:+ CDLL("@libcuda@/libcuda.so.1")+ except OSError:+ pass+ ############################################################################### # Per-thread default stream dispatch@@ -50,14 +58,14 @@ include "../_lib/cyruntime/cyruntime.pxi" cdef cudaError_t _getLocalRuntimeVersion(int* runtimeVersion) except ?cudaErrorCallRequiresNewerDriver nogil: # Load cudart dynamically to read its embedded version number. with gil:- loaded_dl = load_nvidia_dynamic_lib("cudart")- handle = <void *><uintptr_t>loaded_dl._handle_uint+ loaded_dl = CDLL("@libcudart@/lib/libcudart.so")+ handle = <void *><uintptr_t>loaded_dl._handle cdef void* __cudaRuntimeGetVersion = dlfcn.dlsym(handle, 'cudaRuntimeGetVersion') if __cudaRuntimeGetVersion == NULL: with gil:- raise RuntimeError(f'Function "cudaRuntimeGetVersion" not found in {loaded_dl.abs_path}')+ raise RuntimeError(f'Function "cudaRuntimeGetVersion" not found in {loaded_dl._name}') # We explicitly do *NOT* cleanup the library handle here, acknowledging # that, yes, the handle leaks. The reason is that there's a