@@ -12,9 +12,10 @@ cimport cuda.bindings._lib.dlfcn as dlfcn
1212from libc.stdint cimport intptr_t
1313import os
1414import sys
15- import threading
1615cimport cuda.bindings._bindings.loader as loader
17- cdef object __symbol_lock = threading.RLock()
16+ import threading
17+
18+ cdef object __symbol_lock = threading.Lock()
1819cdef bint __cuPythonInit = False
1920{{if 'cuGetErrorString' in found_functions}}cdef void *__cuGetErrorString = NULL{{endif}}
2021{{if 'cuGetErrorName' in found_functions}}cdef void *__cuGetErrorName = NULL{{endif}}
@@ -504,7 +505,7 @@ cdef int cuPythonInit() except -1 nogil:
504505
505506 with gil, __symbol_lock:
506507 usePTDS = os.getenv('CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM', default=0)
507-
508+
508509 # Load library
509510 libPath[0] = 0
510511 status = loader.getCUDALibraryPath(libPath, sys.maxsize > 2**32)
@@ -516,7 +517,7 @@ cdef int cuPythonInit() except -1 nogil:
516517 {{else}}
517518 path = 'libcuda.so.1'
518519 {{endif}}
519-
520+
520521 {{if 'Windows' == platform.system()}}
521522 LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800
522523 try:
@@ -528,7 +529,7 @@ cdef int cuPythonInit() except -1 nogil:
528529 if (handle == NULL):
529530 raise RuntimeError('Failed to dlopen ' + path)
530531 {{endif}}
531-
532+
532533 # Get latest __cuGetProcAddress_v2
533534 global __cuGetProcAddress_v2
534535 {{if 'Windows' == platform.system()}}
@@ -539,7 +540,7 @@ cdef int cuPythonInit() except -1 nogil:
539540 {{else}}
540541 __cuGetProcAddress_v2 = dlfcn.dlsym(handle, 'cuGetProcAddress_v2')
541542 {{endif}}
542-
543+
543544 # Load using cuGetProcAddress if available
544545 if __cuGetProcAddress_v2 != NULL:
545546 _F_cuGetProcAddress_v2 = <__cuGetProcAddress_v2_T>__cuGetProcAddress_v2
@@ -2782,10 +2783,9 @@ cdef int cuPythonInit() except -1 nogil:
27822783 global __cuGraphicsVDPAURegisterOutputSurface
27832784 _F_cuGetProcAddress_v2('cuGraphicsVDPAURegisterOutputSurface', &__cuGraphicsVDPAURegisterOutputSurface, 3010, CU_GET_PROC_ADDRESS_DEFAULT, NULL)
27842785 {{endif}}
2785-
27862786 __cuPythonInit = True
27872787 return 0
2788-
2788+
27892789 {{if 'Windows' == platform.system()}}
27902790 # Load using win32GetAddr
27912791 if usePTDS:
@@ -8943,7 +8943,6 @@ cdef int cuPythonInit() except -1 nogil:
89438943 __cuGraphicsVDPAURegisterOutputSurface = dlfcn.dlsym(handle, 'cuGraphicsVDPAURegisterOutputSurface')
89448944 {{endif}}
89458945 {{endif}}
8946-
89478946 __cuPythonInit = True
89488947 return 0
89498948
0 commit comments