Skip to content

Commit 7e9fce4

Browse files
committed
Enhance to warning messages, to make them actionable.
1 parent c9a95c0 commit 7e9fce4

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

‎cuda_core/cuda/core/experimental/_linker.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,33 @@ def _decide_nvjitlink_or_driver() -> bool:
3939
_driver_ver = handle_return(driver.cuDriverGetVersion())
4040
_driver_ver = (_driver_ver // 1000, (_driver_ver % 1000) // 10)
4141

42+
warn_txt_common = (
43+
"the culink APIs will be used instead, which do not support"
44+
" minor version compatibility or linking LTO IRs."
45+
" For best results, consider upgrading to a recent version of"
46+
)
47+
4248
try:
4349
import cuda.bindings.nvjitlink as _nvjitlink
4450
except ModuleNotFoundError:
45-
warn_txt = "cuda.bindings.nvjitlink is not available, therefore"
51+
warn_txt = f"cuda.bindings.nvjitlink is not available, therefore {warn_txt_common} cuda-bindings."
4652
else:
4753
from cuda.bindings._internal import nvjitlink as inner_nvjitlink
4854

49-
def build_warn_txt(detail):
50-
return (
51-
f"{'nvJitLink*.dll' if sys.platform == 'win32' else 'libnvJitLink.so*'} is {detail}."
52-
" Therefore cuda.bindings.nvjitlink is not usable and"
53-
)
54-
5555
try:
5656
if inner_nvjitlink._inspect_function_pointer("__nvJitLinkVersion"):
5757
return False # Use nvjitlink
5858
except RuntimeError:
59-
warn_txt = build_warn_txt("not available")
59+
warn_detail = "not available"
6060
else:
61-
warn_txt = build_warn_txt("too old (<12.3)")
61+
warn_detail = "too old (<12.3)"
62+
warn_txt = (
63+
f"{'nvJitLink*.dll' if sys.platform == 'win32' else 'libnvJitLink.so*'} is {warn_detail}."
64+
f" Therefore cuda.bindings.nvjitlink is not usable and the {warn_txt_common} nvJitLink."
65+
)
6266
_nvjitlink = None
6367

64-
warn(
65-
warn_txt + " the culink APIs will be used instead.",
66-
stacklevel=2,
67-
category=RuntimeWarning,
68-
)
68+
warn(warn_txt, stacklevel=2, category=RuntimeWarning)
6969
_driver = driver
7070
return True
7171

0 commit comments

Comments
 (0)