|
2 | 2 | # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE |
3 | 3 |
|
4 | 4 | # This code was automatically generated with version 13.0.0. Do not modify it directly. |
| 5 | +from libc.stdint cimport uintptr_t |
5 | 6 | cimport cuda.bindings._bindings.cyruntime as cyruntime |
6 | 7 | cimport cython |
7 | 8 |
|
| 9 | +from cuda.pathfinder import load_nvidia_dynamic_lib |
| 10 | +from pathlib import Path |
| 11 | +{{if 'Windows' == platform.system()}} |
| 12 | +import win32api |
| 13 | +{{else}} |
| 14 | +cimport cuda.bindings._lib.dlfcn as dlfcn |
| 15 | +{{endif}} |
| 16 | + |
8 | 17 | {{if 'cudaDeviceReset' in found_functions}} |
9 | 18 |
|
10 | 19 | cdef cudaError_t cudaDeviceReset() except ?cudaErrorCallRequiresNewerDriver nogil: |
@@ -1885,35 +1894,28 @@ cdef cudaError_t cudaGraphicsVDPAURegisterOutputSurface(cudaGraphicsResource** r |
1885 | 1894 |
|
1886 | 1895 | {{if True}} |
1887 | 1896 |
|
1888 | | -{{if 'Windows' != platform.system()}} |
1889 | | -cimport cuda.bindings._lib.dlfcn as dlfcn |
1890 | | -{{endif}} |
1891 | | - |
1892 | 1897 | cdef cudaError_t getLocalRuntimeVersion(int* runtimeVersion) except ?cudaErrorCallRequiresNewerDriver nogil: |
1893 | | - {{if 'Windows' == platform.system()}} |
1894 | 1898 | with gil: |
1895 | | - raise NotImplementedError('"getLocalRuntimeVersion" is unsupported on Windows') |
1896 | | - {{else}} |
1897 | | - # Load |
1898 | | - handle = dlfcn.dlopen('libcudart.so.13', dlfcn.RTLD_NOW) |
1899 | | - if handle == NULL: |
1900 | | - with gil: |
1901 | | - raise RuntimeError(f'Failed to dlopen libcudart.so.13') |
| 1899 | + lib = load_nvidia_dynamic_lib("cudart") |
| 1900 | + filename = Path(lib.abs_path).name |
| 1901 | + handle = <void *><uintptr_t>lib._handle_uint |
1902 | 1902 |
|
| 1903 | + {{if 'Windows' == platform.system()}} |
| 1904 | + try: |
| 1905 | + __cudaRuntimeGetVersion = <void*><unsigned long long>win32api.GetProcAddress(handle, 'cudaRuntimeGetVersion') |
| 1906 | + except: |
| 1907 | + pass |
| 1908 | + {{else}} |
1903 | 1909 | __cudaRuntimeGetVersion = dlfcn.dlsym(handle, 'cudaRuntimeGetVersion') |
| 1910 | + {{endif}} |
1904 | 1911 |
|
1905 | 1912 | if __cudaRuntimeGetVersion == NULL: |
1906 | 1913 | with gil: |
1907 | | - raise RuntimeError(f'Function "cudaRuntimeGetVersion" not found in libcudart.so.13') |
| 1914 | + raise RuntimeError(f'Function "cudaRuntimeGetVersion" not found in {filename}') |
1908 | 1915 |
|
1909 | | - # Call |
1910 | 1916 | cdef cudaError_t err = cudaSuccess |
1911 | 1917 | err = (<cudaError_t (*)(int*) except ?cudaErrorCallRequiresNewerDriver nogil> __cudaRuntimeGetVersion)(runtimeVersion) |
1912 | 1918 |
|
1913 | | - # Unload |
1914 | | - dlfcn.dlclose(handle) |
1915 | | - |
1916 | 1919 | # Return |
1917 | 1920 | return err |
1918 | | - {{endif}} |
1919 | 1921 | {{endif}} |
0 commit comments