Uh oh!
There was an error while loading. Please reload this page.
Fix skipping the check for nvidia-smi - #1084
Conversation
leofang
commented
Oct 3, 2025
/ok to test 4e19418 |
| if m: | ||
| return m.group(1).split(".")[0] | ||
| except FileNotFoundError: | ||
| except (FileNotFoundError, subprocess.CalledProcessError): |
There was a problem hiding this comment.
TODO: use shutil.which, since CalledProcessError can be literally any error that comes from running the command.
Not blocking the review though!
This comment has been minimized.
This comment has been minimized.
kkraus14
commented
Oct 3, 2025
Using |
cpcloud
commented
Oct 3, 2025
In theory, one could also not have |
rwgk
commented
Oct 3, 2025
Purely as a bug fix this PR seems fine to me. But bigger picture: For building we don't actually need a GPU, so the driver version and nvidia-smi don't meaningfully matter (what @kkraus14 and @cpcloud said already). We already have a hard requirement that cuda-python/cuda_core/build_hooks.py Lines 76 to 83 in 872c68e That defines conclusively what CUDA version the build is for. We are also sure that we need the headers for the build. So in the given context this should always work: Maybe a better fix is to integrate something like this? from __future__ importannotationsimportrefrompathlibimportPathdefget_cuda_version_macro(cuda_home: str|Path) ->int|None:
""" Given CUDA_HOME, try to extract the CUDA_VERSION macro from include/cuda.h. Example line in cuda.h: #define CUDA_VERSION 13000 Returns the integer (e.g. 13000) or None if not found / on error. """try:
cuda_h=Path(cuda_home) /"include"/"cuda.h"ifnotcuda_h.is_file():
returnNonetext=cuda_h.read_text(encoding="utf-8", errors="ignore")
m=re.search(r"^\s*#define\s+CUDA_VERSION\s+(\d+)", text, re.MULTILINE)
ifm:
returnint(m.group(1))
exceptException:
passreturnNone |
Yes switching to check the major version based on |
Well let me take a step back. There is a reason that we want nvidia-smi to play a role. For local development, if the user does not already have cuda-bindings installed (thus triggering the latter checks) we want to ensure we build a cuda.core that uses cuda.bindings whose version is runnable on the user's driver. Now, we don't have a way to inject extra run-time dependencies through the build time info yet, so this is not fully doable, but at least we can think about how this can be approached and see the value of checking driver versions. |
rwgk
commented
Oct 3, 2025
I looked into that, too (before already), I'm attaching the POC implementation for Linux; I believe Windows will work similarly. The reasoning behind it:
from __future__ importannotationsimportctypesimportosfromtypingimportOptionaldefcuda_driver_version() ->Optional[int]:
""" Linux-only. Try to load `libcuda.so` via standard dynamic library lookup and call `CUresult cuDriverGetVersion(int* driverVersion)`. Returns: int : driver version (e.g., 12040 for 12.4), if successful. None : on any failure (load error, missing symbol, non-success CUresult). """# CUDA_SUCCESS = 0CUDA_SUCCESS=0try:
# Use system search paths only; do not provide an absolute path.# Make symbols globally available to any dependent libraries.mode=os.RTLD_NOW|os.RTLD_GLOBALlib=ctypes.CDLL("libcuda.so", mode=mode)
exceptOSError:
returnNonetry:
cuDriverGetVersion=lib.cuDriverGetVersionexceptAttributeError:
# Symbol not found in the loaded library.returnNone# int cuDriverGetVersion(int* driverVersion);cuDriverGetVersion.restype=ctypes.c_int# CUresultcuDriverGetVersion.argtypes= [ctypes.POINTER(ctypes.c_int)]
out=ctypes.c_int(0)
try:
rc=cuDriverGetVersion(ctypes.byref(out))
exceptException:
returnNoneifrc!=CUDA_SUCCESS:
returnNonereturnint(out.value)
if__name__=="__main__":
print(cuda_driver_version()) |
For this PR, I'd say just merge, it's definitely an improvement, and it exists already. I'll work on another PR to integrate the |
Uh oh!
There was an error while loading. Please reload this page.
|
* _decide_nvjitlink_or_driver(): catch RuntimeError (bug fix), use importlib + ModuleNotFoundError (more selective than ImportError) and produce specific error messages * Fix misunderstanding: RuntimeError is raised only from inner_nvjitlink._inspect_function_pointer() * Better way of formatting warning messages. * Change from importlib.import_module() to plain import (the latter does also raise ModuleNotFoundError) * Enhance to warning messages, to make them actionable. * Factor out _nvjitlink_has_version_symbol() for clarity and testability This aids unit testing by allowing localized stubbing of the version-symbol check, without needing to patch the full inner nvjitlink module. * Add test_linker_warnings.py As generated by ChatGPT 5, with minor manual tweaks. * Fix "the the" oversight * Replace "culink APIs" → "driver APIs" in warning message. * Fix oversight: test_linker_warnings.py needs to be updated after commit 0948942 * fix skipping the check for nvidia-smi (#1084) * rm cuda_core/tests/test_linker_warnings.py: see #1095 --------- Co-authored-by: Leo Fang <leof@nvidia.com>
Description
Found during local debugging with Andy.
Checklist