Skip to content

Commit 886dcdd

Browse files
committed
Catch RuntimeError from missing PCH symbols in old libnvrtc
When cuda.bindings is built against a newer toolkit but runs with an older libnvrtc.so that lacks the PCH C symbols, the binding wrappers exist (hasattr passes) but the actual call raises RuntimeError from failing to resolve the function pointer at runtime. Extract PCH status/retry logic into _pch_status_and_retry() and wrap the call in try/except RuntimeError so we gracefully degrade to pch_status=None instead of crashing. Made-with: Cursor
1 parent 12d2551 commit 886dcdd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cuda_core/cuda/core/_program.pyx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,14 @@ cdef object Program_compile_nvrtc(Program self, str target_type, object name_exp
797797
self._pch_status = None
798798
return result
799799

800-
# PCH was requested — check creation status
801-
cdef str status = _read_pch_status(prog)
800+
try:
801+
status = _read_pch_status(prog)
802+
except RuntimeError as e:
803+
raise RuntimeError(
804+
"PCH was requested but the runtime libnvrtc does not support "
805+
"PCH APIs. Update to CUDA toolkit 12.8 or newer."
806+
) from e
807+
802808
if status is not None:
803809
self._pch_status = status
804810
return result

0 commit comments

Comments
 (0)