Skip to content

Commit db571f4

Browse files
committed
Report dlopen error for libnvrtc.so.12
1 parent 69967c7 commit db571f4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ cdef bint __cuPythonInit = False
4646
{{if 'nvrtcSetFlowCallback' in found_functions}}cdef void *__nvrtcSetFlowCallback = NULL{{endif}}
4747

4848
cdef int cuPythonInit() except -1 nogil:
49+
{{if 'Windows' != platform.system()}}
50+
cdef char* err_msg
51+
{{endif}}
52+
4953
global __cuPythonInit
5054
if __cuPythonInit:
5155
return 0
@@ -97,7 +101,12 @@ cdef int cuPythonInit() except -1 nogil:
97101
handle = dlfcn.dlopen('libnvrtc.so.12', dlfcn.RTLD_NOW)
98102
if handle == NULL:
99103
with gil:
100-
raise RuntimeError('Failed to dlopen libnvrtc.so.12')
104+
err_msg = dlfcn.dlerror()
105+
if err_msg == NULL:
106+
err_msg_str = 'Unknown error'
107+
else:
108+
err_msg_str = err_msg.decode('utf-8', errors='backslashreplace')
109+
raise RuntimeError(f'Failed to dlopen libnvrtc.so.12: {err_msg_str}')
101110
{{endif}}
102111

103112

0 commit comments

Comments
 (0)