File tree Expand file tree Collapse file tree 2 files changed +5
-31
lines changed
cuda_bindings/cuda/bindings/_internal Expand file tree Collapse file tree 2 files changed +5
-31
lines changed Original file line number Diff line number Diff line change @@ -406,7 +406,8 @@ cdef void* __nvmlDeviceSetRusdSettings_v1 = NULL
406406
407407
408408cdef void * load_library() except * with gil:
409- return dlopen(" libnvidia-ml.so.1" , RTLD_NOW | RTLD_GLOBAL)
409+ cdef uintptr_t handle = load_nvidia_dynamic_lib(" nvml" )._handle_uint
410+ return < void * > handle
410411
411412
412413cdef int _init_nvml() except - 1 nogil:
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ from libc.stdint cimport intptr_t
99import os
1010import threading
1111
12+ from cuda.pathfinder import load_nvidia_dynamic_lib
13+
1214from .utils import FunctionNotFoundError, NotSupportedError
1315
1416from libc.stddef cimport wchar_t
@@ -422,43 +424,14 @@ cdef void* __nvmlDeviceReadPRMCounters_v1 = NULL
422424cdef void * __nvmlDeviceSetRusdSettings_v1 = NULL
423425
424426
425- cdef uintptr_t load_library() except * with gil:
426- def do_load (path ):
427- return LoadLibraryExW(
428- path,
429- < void * > 0 ,
430- LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
431- )
432-
433- handle = do_load(
434- os.path.join(
435- os.getenv(" WINDIR" , " C:/Windows" ),
436- " System32/nvml.dll"
437- )
438- )
439- if handle:
440- return handle
441-
442- handle = do_load(
443- os.path.join(
444- os.getenv(" ProgramFiles" , " C:/Program Files" ),
445- " NVIDIA Corporation/NVSMI/nvml.dll"
446- )
447- )
448- if handle:
449- return handle
450-
451- return 0
452-
453-
454427cdef int _init_nvml() except - 1 nogil:
455428 global __py_nvml_init
456429
457430 cdef int err, driver_ver = 0
458431 cdef uintptr_t handle
459432
460433 with gil, __symbol_lock:
461- handle = load_library()
434+ handle = load_nvidia_dynamic_lib( " nvml " )._handle_uint
462435
463436 # Load function
464437 global __nvmlInit_v2
You can’t perform that action at this time.
0 commit comments