Skip to content

Commit ed44ae1

Browse files
committed
Update to not use pywin32
1 parent 1c1547e commit ed44ae1

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

cuda_bindings/cuda/bindings/cyruntime.pyx.in

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33

44
# This code was automatically generated with version 13.0.0. Do not modify it directly.
5-
from libc.stdint cimport uintptr_t
65
cimport cuda.bindings._bindings.cyruntime as cyruntime
76
cimport cython
87

9-
from cuda.pathfinder import load_nvidia_dynamic_lib
10-
{{if 'Windows' == platform.system()}}
11-
import win32api
12-
{{else}}
13-
cimport cuda.bindings._lib.dlfcn as dlfcn
14-
{{endif}}
15-
168
{{if 'cudaDeviceReset' in found_functions}}
179

1810
cdef cudaError_t cudaDeviceReset() except ?cudaErrorCallRequiresNewerDriver nogil:
@@ -1893,23 +1885,36 @@ cdef cudaError_t cudaGraphicsVDPAURegisterOutputSurface(cudaGraphicsResource** r
18931885

18941886
{{if True}}
18951887

1888+
from libc.stdint cimport uintptr_t
1889+
from cuda.pathfinder import load_nvidia_dynamic_lib
1890+
{{if 'Windows' == platform.system()}}
1891+
cimport cuda.bindings._lib.windll as windll
1892+
{{else}}
1893+
cimport cuda.bindings._lib.dlfcn as dlfcn
1894+
{{endif}}
1895+
18961896
cdef cudaError_t getLocalRuntimeVersion(int* runtimeVersion) except ?cudaErrorCallRequiresNewerDriver nogil:
1897+
1898+
# Load
18971899
with gil:
18981900
lib = load_nvidia_dynamic_lib("cudart")
1899-
handle = <void *><uintptr_t>(lib._handle_uint)
1901+
handle = <void *><uintptr_t>lib._handle_uint
19001902

1901-
{{if 'Windows' == platform.system()}}
1902-
__cudaRuntimeGetVersion = <void*><unsigned long long>win32api.GetProcAddress(<uintptr_t>handle, 'cudaRuntimeGetVersion')
1903-
{{else}}
1904-
__cudaRuntimeGetVersion = dlfcn.dlsym(handle, 'cudaRuntimeGetVersion')
1905-
{{endif}}
1903+
{{if 'Windows' == platform.system()}}
1904+
__cudaRuntimeGetVersion = windll.GetProcAddress(handle, b'cudaRuntimeGetVersion')
1905+
{{else}}
1906+
__cudaRuntimeGetVersion = dlfcn.dlsym(handle, 'cudaRuntimeGetVersion')
1907+
{{endif}}
19061908

1907-
if __cudaRuntimeGetVersion == NULL:
1909+
if __cudaRuntimeGetVersion == NULL:
1910+
with gil:
19081911
raise RuntimeError(f'Function "cudaRuntimeGetVersion" not found in {lib.abs_path}')
19091912

1913+
# Call
19101914
cdef cudaError_t err = cudaSuccess
19111915
err = (<cudaError_t (*)(int*) except ?cudaErrorCallRequiresNewerDriver nogil> __cudaRuntimeGetVersion)(runtimeVersion)
19121916

1917+
# Unload
19131918
{{if 'Windows' != platform.system()}}
19141919
dlfcn.dlclose(handle)
19151920
{{endif}}

0 commit comments

Comments
 (0)