Skip to content

Commit 00a216b

Browse files
committed
Backport #865 to 12.9.x
* Only raise on cuda.bindings modules
1 parent 2435550 commit 00a216b

File tree

17 files changed

+755
-478
lines changed

17 files changed

+755
-478
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ __pycache__/
1616
cache_driver
1717
cache_runtime
1818
cache_nvrtc
19+
cuda_bindings/cuda/bindings/_lib/utils.pxi
1920

2021
# CUDA Python specific (auto-generated)
2122
cuda_bindings/cuda/bindings/_bindings/cydriver.pxd

cuda_bindings/cuda/bindings/_bindings/cydriver.pyx.in

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ cimport cuda.bindings._lib.dlfcn as dlfcn
1212
from libc.stdint cimport intptr_t
1313
import os
1414
import sys
15-
import threading
1615
cimport cuda.bindings._bindings.loader as loader
17-
cdef object __symbol_lock = threading.RLock()
16+
import threading
17+
18+
cdef object __symbol_lock = threading.Lock()
1819
cdef 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

cuda_bindings/cuda/bindings/_bindings/cynvrtc.pyx.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ from libc.stdint cimport uintptr_t
1212
from cuda.pathfinder import load_nvidia_dynamic_lib
1313
from libc.stdint cimport intptr_t
1414
import threading
15+
1516
cdef object __symbol_lock = threading.Lock()
1617
cdef bint __cuPythonInit = False
1718
{{if 'nvrtcGetErrorString' in found_functions}}cdef void *__nvrtcGetErrorString = NULL{{endif}}
@@ -343,8 +344,8 @@ cdef int cuPythonInit() except -1 nogil:
343344
global __nvrtcSetFlowCallback
344345
__nvrtcSetFlowCallback = dlfcn.dlsym(handle, 'nvrtcSetFlowCallback')
345346
{{endif}}
346-
{{endif}}
347347

348+
{{endif}}
348349
__cuPythonInit = True
349350
return 0
350351

cuda_bindings/cuda/bindings/_lib/param_packer.cpp

Lines changed: 0 additions & 159 deletions
This file was deleted.

0 commit comments

Comments
 (0)