Skip to content

Commit cdecc5f

Browse files
committed
add regression test, driver log could be non zero, for example per cudaVersion argument (13030) exceeds the driver version (13020)
1 parent 474b3b6 commit cdecc5f

1 file changed

Lines changed: 8 additions & 28 deletions

File tree

‎cuda_bindings/tests/test_cuda.py‎

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -981,30 +981,7 @@ def test_cuCheckpointProcessGetState_failure():
981981
driver_version_less_than(12090),
982982
reason="cuLogs* functions were introduced in CUDA 12.9",
983983
)
984-
def test_culogs_functions_are_resolved():
985-
"""
986-
Regression test for https://github.com/NVIDIA/cuda-python/issues/2979
987-
988-
cuLogsRegisterCallback, cuLogsUnregisterCallback, cuLogsCurrent,
989-
cuLogsDumpToFile, and cuLogsDumpToMemory were introduced in CUDA 12.9,
990-
but were incorrectly requested from cuGetProcAddress_v2 with version
991-
12080 (CUDA 12.8). On a driver that enforces the requested symbol
992-
version, that mismatch causes the internal function pointer to never
993-
be resolved, so calling the function raises FunctionNotFoundError
994-
instead of actually invoking the driver.
995-
996-
cuLogsRegisterCallback, cuLogsUnregisterCallback, cuLogsCurrent, and
997-
cuLogsDumpToFile are called directly below since they can be exercised
998-
safely without a real log message or a fixed-size memory buffer. We
999-
deliberately avoid calling cuLogsDumpToMemory with a real buffer here:
1000-
it writes a driver-chosen amount of data into the caller-supplied
1001-
buffer, which makes it unsafe to invoke blindly in a regression test.
1002-
Instead, its resolution is verified the same way
1003-
test_private_function_pointer_inspector does: by inspecting the
1004-
internal function pointer directly.
1005-
"""
1006-
from cuda.bindings._internal.driver import _inspect_function_pointer
1007-
984+
def test_culogs_functions():
1008985
try:
1009986
err, callback_handle = cuda.cuLogsRegisterCallback(0, None)
1010987
assert err == cuda.CUresult.CUDA_SUCCESS
@@ -1020,15 +997,18 @@ def test_culogs_functions_are_resolved():
1020997
finally:
1021998
os.remove(log_path)
1022999

1000+
# cuLogsDumpToMemory's own docstring states the driver's internal log
1001+
# buffer is capped at 25600 bytes, so a buffer of that size is always
1002+
# large enough to hold the dump without risking a buffer overrun.
1003+
buf = bytearray(25600)
1004+
err, _, _ = cuda.cuLogsDumpToMemory(None, buf, len(buf), 0)
1005+
assert err == cuda.CUresult.CUDA_SUCCESS
1006+
10231007
(err,) = cuda.cuLogsUnregisterCallback(callback_handle)
10241008
assert err == cuda.CUresult.CUDA_SUCCESS
10251009
except FunctionNotFoundError as e:
10261010
pytest.fail(f"cuLogs* function unexpectedly not found on the driver: {e}")
10271011

1028-
assert _inspect_function_pointer("__cuLogsDumpToMemory") != 0, (
1029-
"cuLogsDumpToMemory was not resolved by cuGetProcAddress_v2"
1030-
)
1031-
10321012

10331013
def test_private_function_pointer_inspector():
10341014
from cuda.bindings._internal.driver import _inspect_function_pointer

0 commit comments

Comments
 (0)