Skip to content

Commit 252f5c2

Browse files
lijinf2claude
andcommitted
[no-ci] fix(driver): correct cuLogs* introduced version to 12.9 in cuda_bindings_12
Apply the changes from #2978 to cuda_bindings_12/ on main: pin the cuGetProcAddress_v2 version for cuLogs* to 12090 (was 12080) and add a regression test. This fixes the cuLogs* FunctionNotFoundError. Matches the 12.9.x backport in #3377. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent b3c5fb2 commit 252f5c2

3 files changed

Lines changed: 48 additions & 12 deletions

File tree

‎cuda_bindings_12/cuda/bindings/_internal/driver_linux.pyx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55
# This code was automatically generated with version 12.9.0. Do not modify it directly.
6-
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=c4957d188c7c3258823fd50e2eb0cba162810911af7294ab726f1e49769642c8
6+
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=d382464130e581b718a589e652053c30057e65ddc824b2c79a903341858f1e88
77

88

99
# <<<< PREAMBLE CONTENT >>>>
@@ -1894,19 +1894,19 @@ cdef int _init_driver() except -1 nogil:
18941894
cuGetProcAddress_v2('cuGreenCtxStreamCreate', <void **>&__cuGreenCtxStreamCreate, 12050, ptds_mode, NULL)
18951895

18961896
global __cuLogsRegisterCallback
1897-
cuGetProcAddress_v2('cuLogsRegisterCallback', <void **>&__cuLogsRegisterCallback, 12080, ptds_mode, NULL)
1897+
cuGetProcAddress_v2('cuLogsRegisterCallback', <void **>&__cuLogsRegisterCallback, 12090, ptds_mode, NULL)
18981898

18991899
global __cuLogsUnregisterCallback
1900-
cuGetProcAddress_v2('cuLogsUnregisterCallback', <void **>&__cuLogsUnregisterCallback, 12080, ptds_mode, NULL)
1900+
cuGetProcAddress_v2('cuLogsUnregisterCallback', <void **>&__cuLogsUnregisterCallback, 12090, ptds_mode, NULL)
19011901

19021902
global __cuLogsCurrent
1903-
cuGetProcAddress_v2('cuLogsCurrent', <void **>&__cuLogsCurrent, 12080, ptds_mode, NULL)
1903+
cuGetProcAddress_v2('cuLogsCurrent', <void **>&__cuLogsCurrent, 12090, ptds_mode, NULL)
19041904

19051905
global __cuLogsDumpToFile
1906-
cuGetProcAddress_v2('cuLogsDumpToFile', <void **>&__cuLogsDumpToFile, 12080, ptds_mode, NULL)
1906+
cuGetProcAddress_v2('cuLogsDumpToFile', <void **>&__cuLogsDumpToFile, 12090, ptds_mode, NULL)
19071907

19081908
global __cuLogsDumpToMemory
1909-
cuGetProcAddress_v2('cuLogsDumpToMemory', <void **>&__cuLogsDumpToMemory, 12080, ptds_mode, NULL)
1909+
cuGetProcAddress_v2('cuLogsDumpToMemory', <void **>&__cuLogsDumpToMemory, 12090, ptds_mode, NULL)
19101910

19111911
global __cuCheckpointProcessGetRestoreThreadId
19121912
cuGetProcAddress_v2('cuCheckpointProcessGetRestoreThreadId', <void **>&__cuCheckpointProcessGetRestoreThreadId, 12080, ptds_mode, NULL)

‎cuda_bindings_12/cuda/bindings/_internal/driver_windows.pyx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55
# This code was automatically generated with version 12.9.0. Do not modify it directly.
6-
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=d36a59b7d4c8939f88b07a4600cbd4251a2ed69571b425bb6009a626cfd4dc3e
6+
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=895c345db6512915d2c6c9f27757175413ce053e7356b6eeb890478159cdc918
77

88

99
# <<<< PREAMBLE CONTENT >>>>
@@ -1897,19 +1897,19 @@ cdef int _init_driver() except -1 nogil:
18971897
cuGetProcAddress_v2('cuGreenCtxStreamCreate', <void **>&__cuGreenCtxStreamCreate, 12050, ptds_mode, NULL)
18981898

18991899
global __cuLogsRegisterCallback
1900-
cuGetProcAddress_v2('cuLogsRegisterCallback', <void **>&__cuLogsRegisterCallback, 12080, ptds_mode, NULL)
1900+
cuGetProcAddress_v2('cuLogsRegisterCallback', <void **>&__cuLogsRegisterCallback, 12090, ptds_mode, NULL)
19011901

19021902
global __cuLogsUnregisterCallback
1903-
cuGetProcAddress_v2('cuLogsUnregisterCallback', <void **>&__cuLogsUnregisterCallback, 12080, ptds_mode, NULL)
1903+
cuGetProcAddress_v2('cuLogsUnregisterCallback', <void **>&__cuLogsUnregisterCallback, 12090, ptds_mode, NULL)
19041904

19051905
global __cuLogsCurrent
1906-
cuGetProcAddress_v2('cuLogsCurrent', <void **>&__cuLogsCurrent, 12080, ptds_mode, NULL)
1906+
cuGetProcAddress_v2('cuLogsCurrent', <void **>&__cuLogsCurrent, 12090, ptds_mode, NULL)
19071907

19081908
global __cuLogsDumpToFile
1909-
cuGetProcAddress_v2('cuLogsDumpToFile', <void **>&__cuLogsDumpToFile, 12080, ptds_mode, NULL)
1909+
cuGetProcAddress_v2('cuLogsDumpToFile', <void **>&__cuLogsDumpToFile, 12090, ptds_mode, NULL)
19101910

19111911
global __cuLogsDumpToMemory
1912-
cuGetProcAddress_v2('cuLogsDumpToMemory', <void **>&__cuLogsDumpToMemory, 12080, ptds_mode, NULL)
1912+
cuGetProcAddress_v2('cuLogsDumpToMemory', <void **>&__cuLogsDumpToMemory, 12090, ptds_mode, NULL)
19131913

19141914
global __cuCheckpointProcessGetRestoreThreadId
19151915
cuGetProcAddress_v2('cuCheckpointProcessGetRestoreThreadId', <void **>&__cuCheckpointProcessGetRestoreThreadId, 12080, ptds_mode, NULL)

‎cuda_bindings_12/tests/test_cuda.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
import ctypes
5+
import os
56
import platform
67
import shutil
8+
import tempfile
79
import textwrap
810

911
import numpy as np
1012
import pytest
1113

1214
import cuda.cuda as cuda
1315
from cuda.bindings import driver
16+
from cuda.bindings._internal.utils import FunctionNotFoundError
1417
from cuda_python_test_helpers import driver_version_less_than
1518
from cuda_python_test_helpers.memory import (
1619
POOL_SIZE,
@@ -1153,6 +1156,39 @@ def test_cuCheckpointProcessGetState_failure():
11531156
assert state is None
11541157

11551158

1159+
@pytest.mark.skipif(
1160+
driver_version_less_than(12090),
1161+
reason="cuLogs* functions were introduced in CUDA 12.9",
1162+
)
1163+
def test_culogs_functions():
1164+
try:
1165+
err, callback_handle = cuda.cuLogsRegisterCallback(0, None)
1166+
assert err == cuda.CUresult.CUDA_SUCCESS
1167+
1168+
err, _ = cuda.cuLogsCurrent(0)
1169+
assert err == cuda.CUresult.CUDA_SUCCESS
1170+
1171+
with tempfile.NamedTemporaryFile(delete=False) as f:
1172+
log_path = f.name
1173+
try:
1174+
err, _ = cuda.cuLogsDumpToFile(None, log_path.encode(), 0)
1175+
assert err == cuda.CUresult.CUDA_SUCCESS
1176+
finally:
1177+
os.remove(log_path)
1178+
1179+
# cuLogsDumpToMemory's own docstring states the driver's internal log
1180+
# buffer is capped at 25600 bytes, so a buffer of that size is always
1181+
# large enough to hold the dump without risking a buffer overrun.
1182+
buf = bytearray(25600)
1183+
err, _, _ = cuda.cuLogsDumpToMemory(None, buf, len(buf), 0)
1184+
assert err == cuda.CUresult.CUDA_SUCCESS
1185+
1186+
(err,) = cuda.cuLogsUnregisterCallback(callback_handle)
1187+
assert err == cuda.CUresult.CUDA_SUCCESS
1188+
except FunctionNotFoundError as e:
1189+
pytest.fail(f"cuLogs* function unexpectedly not found on the driver: {e}")
1190+
1191+
11561192
def test_private_function_pointer_inspector():
11571193
from cuda.bindings._internal.driver import _inspect_function_pointer
11581194

0 commit comments

Comments
 (0)