Skip to content

Commit 00ea580

Browse files
committed
Attempt to fix Windows build
1 parent f664c86 commit 00ea580

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

cuda_bindings/cuda/bindings/_internal/driver_windows.pyx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,11 @@ cdef void* __cuCoredumpDeregisterStartCallback = NULL
581581
cdef void* __cuCoredumpDeregisterCompleteCallback = NULL
582582

583583

584+
cdef void* load_library() except* with gil:
585+
cdef uintptr_t handle = load_nvidia_dynamic_lib("cuda")._handle_uint
586+
return <void*>handle
587+
588+
584589
ctypedef CUresult (*__cuGetProcAddress_v2_T)(const char*, void**, int, cuuint64_t, CUdriverProcAddressQueryResult*) except?CUDA_ERROR_NOT_FOUND nogil
585590
cdef __cuGetProcAddress_v2_T _F_cuGetProcAddress_v2 = NULL
586591

@@ -597,11 +602,13 @@ cdef int _init_driver() except -1 nogil:
597602
return 0
598603

599604
# Load library
600-
handle = load_nvidia_dynamic_lib("cuda")._handle_uint
605+
handle = load_library()
606+
if handle == NULL:
607+
raise RuntimeError('Failed to open cuda')
601608

602609
# Get latest __cuGetProcAddress_v2
603610
global __cuGetProcAddress_v2
604-
__cuGetProcAddress_v2 = windll.GetProcAddress(handle, 'cuGetProcAddress_v2')
611+
__cuGetProcAddress_v2 = GetProcAddress(handle, 'cuGetProcAddress_v2')
605612
if __cuGetProcAddress_v2 == NULL:
606613
raise RuntimeError("Failed to get __cuGetProcAddress_v2")
607614
_F_cuGetProcAddress_v2 = <__cuGetProcAddress_v2_T>__cuGetProcAddress_v2

0 commit comments

Comments
 (0)