Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cuda_core/cuda/core/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
StridedMemoryView,
args_viewable_as_strided_memory,
)
from cuda.core.utils._logging import (
register_cuda_error_log,
unregister_cuda_error_log,
)
from cuda.core.utils._program_cache import (
FileStreamProgramCache,
InMemoryProgramCache,
Expand All @@ -38,4 +42,6 @@
"discard_prefetch_batch",
"make_program_cache_key",
"prefetch_batch",
"register_cuda_error_log",
"unregister_cuda_error_log",
]
121 changes: 121 additions & 0 deletions cuda_core/cuda/core/utils/_logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

"""Bridge CUDA driver error logs into Python's :mod:`logging` module via
the ``cuLogs*`` API.
"""

from __future__ import annotations

import ctypes
import logging
import threading
from typing import Callable

from cuda.bindings import driver as _driver
from cuda.core._utils.cuda_utils import handle_return

__all__ = ["register_cuda_error_log", "unregister_cuda_error_log"]

# C callback signature for cuLogsRegisterCallback:
# void callback(void *userData, CUlogLevel logLevel, char *message, size_t length)
_CUlogsCallback_functype = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_size_t)
PyLogCallback = Callable[[int, bytes], None]

# Keep a reference while registered, or GC'ing it leaves the driver with
# a dangling function pointer which will crash on the next log message.
_lock = threading.Lock()
_c_callback: ctypes._FuncPointer | None = None
_callback_handle = None # CUlogsCallbackHandle, needed to unregister


def _make_c_callback(logger: logging.Logger, callback: PyLogCallback | None) -> ctypes._FuncPointer:
"""Build the ctypes C callback passed to cuLogsRegisterCallback."""

def _default_callback(cu_log_level: int, message: bytes) -> None:
cuda_level_to_py_level = {
int(_driver.CUlogLevel.CU_LOG_LEVEL_ERROR): logging.ERROR,
int(_driver.CUlogLevel.CU_LOG_LEVEL_WARNING): logging.WARNING,
}
msg = message.decode("utf-8", errors="replace").rstrip("\n")
py_level = cuda_level_to_py_level.get(cu_log_level, logging.ERROR)
logger.log(py_level, "[CUDA Driver] %s", msg)

emit = callback if callback is not None else _default_callback

def _on_log(_user_data, log_level, message_ptr, length):
try:
message = ctypes.string_at(message_ptr, length) if message_ptr else b""
emit(log_level, message)
except Exception:
logger.exception("cuda_error_log: error while forwarding driver log")

return _CUlogsCallback_functype(_on_log)


def register_cuda_error_log(
logger: logging.Logger | None = None,
callback: PyLogCallback | None = None,
) -> logging.Logger:
"""Register a bridge that forwards CUDA driver ``cuLogs*`` messages to
a Python :class:`logging.Logger`.

Parameters
----------
logger : logging.Logger, optional
Target logger. If not provided, a default is created via
``logging.getLogger("cuda.driver")``.
callback : Callable[[int, bytes], None], optional
Overrides the default forwarding. Called as
``callback(cu_log_level, message)`` with undecoded ``message`` and
unmapped ``cu_log_level``; decoding/mapping is the callback's job.

Returns
-------
logging.Logger
The ``logger`` argument above (or the default logger it resolved
to). If a bridge was already registered, it is unregistered first,
so this logger/callback replaces it.

"""
global _c_callback, _callback_handle

if logger is None:
logger = logging.getLogger("cuda.driver")

if callback is not None and not callable(callback):
raise TypeError(f"callback must be callable or None, got {type(callback)!r}")

with _lock:
if _callback_handle is not None:
# Already registered: unregister the old callback/handle first,
# then fall through to register the new logger/callback below.
handle_return(_driver.cuLogsUnregisterCallback(_callback_handle))
_c_callback = None
_callback_handle = None

c_callback = _make_c_callback(logger, callback)
addr = ctypes.cast(c_callback, ctypes.c_void_p).value

handle = handle_return(_driver.cuLogsRegisterCallback(addr, None))

# Keep the ctypes callback alive (see _c_callback comment above).
_c_callback = c_callback
_callback_handle = handle

return logger


def unregister_cuda_error_log() -> None:
"""Unregister the bridge installed by :func:`register_cuda_error_log`."""
global _c_callback, _callback_handle

with _lock:
if _callback_handle is None:
return

handle_return(_driver.cuLogsUnregisterCallback(_callback_handle))

_c_callback = None
_callback_handle = None
15 changes: 15 additions & 0 deletions cuda_core/docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ avoid recompiling identical source + options + target without writing the
make_program_cache_key


Driver logging
``````````````

:func:`~cuda.core.utils.register_cuda_error_log` bridges CUDA driver
``cuLogs*`` messages into Python's standard :mod:`logging` module.
Comment on lines +132 to +133

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -i 'register_cuda_error_log|unregister_cuda_error_log|driver logging|driver log' cuda_core/docs/source/release

Repository: NVIDIA/cuda-python

Length of output: 156


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- release files ---'
rg --files cuda_core/docs/source/release
printf '%s\n' '--- logging-related release text ---'
rg -n -i 'log|cuda\.core\.utils|public api|api' cuda_core/docs/source/release || test "$?" -eq 1

Repository: NVIDIA/cuda-python

Length of output: 7273


important: Add a release-note entry for register_cuda_error_log and unregister_cuda_error_log. The release notes contain no entry for this new public API or CUDA driver logging.

Source: Path instructions


.. currentmodule:: cuda.core.utils

.. autosummary::
:toctree: generated/

register_cuda_error_log
unregister_cuda_error_log


CUDA graphs
-----------

Expand Down
176 changes: 176 additions & 0 deletions cuda_core/tests/test_cuda_log_bridge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

"""Tests for bridging CUDA driver ``cuLogs*`` messages into Python
``logging`` (see design doc / GitHub issue #671).
"""

import logging

import pytest

from cuda.bindings import driver
from cuda.core.utils import register_cuda_error_log, unregister_cuda_error_log


@pytest.fixture(autouse=True)
def teardown_bridge():
yield
# Unregister after every test so a leaked bridge can't leak into others.
unregister_cuda_error_log()
Comment on lines +17 to +21

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

important: Nothing in this module skips the tests when the driver is older than CUDA 12.9, where cuLogs* does not exist. On such drivers, register_cuda_error_log raises and every forwarding test fails instead of being skipped. The bindings test in cuda_bindings/tests/test_cuda.py:977-1007 already guards the same API with driver_version_less_than(12090). Add an equivalent module-level skipif here.



# Usage 1: show driver error log interactively
def test_cuda_driver_log_captured_via_caplog(caplog):
driver.cuInit(0)

logger_name = "cuda.driver.caplog_test"
logger_obj = logging.getLogger(logger_name)
register_cuda_error_log(logger_obj)

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU rtxpro6000

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU rtxpro6000

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 12.9.1 (wheels), GPU a100

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 12.9.1 (local), GPU v100

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 12.9.1 (local), GPU a100

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU h100

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 12.9.1 (local), GPU t4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 12.9.1 (wheels), GPU t4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.0.2 (wheels), GPU a100

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 12.9.1 (local), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 30 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU t4, wsl

test_cuda_driver_log_captured_via_caplog cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

# cuDeviceGet(9999) is out of range; driver writes two ERROR logs
with caplog.at_level(logging.ERROR, logger=logger_name):
driver.cuDeviceGet(9999)
Comment on lines +32 to +34

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

printf '%s\n' '--- cuda_core/tests/AGENTS.md ---'
nl -ba cuda_core/tests/AGENTS.md
printf '%s\n' '--- test module ---'
nl -ba cuda_core/tests/test_cuda_log_bridge.py
printf '%s\n' '--- relevant conftest fixtures ---'
nl -ba cuda_core/tests/conftest.py | sed -n '210,245p'
printf '%s\n' '--- changed test diff ---'
git diff 0271e3ad33d56bd34530110a1decb8bebfdb0cb4 4e823c9fa263b0c817941be0e94887b71137abaf -- cuda_core/tests/test_cuda_log_bridge.py

Repository: NVIDIA/cuda-python

Length of output: 29840


important: Establish a current CUDA context for these driver tests.

driver.cuInit(0) initializes the driver but does not set a current context. The six tests that call driver.cuDeviceGet(9999) therefore violate cuda_core/tests/AGENTS.md and can inherit no or stale context. Add init_cuda independently of any skip for unsupported driver versions.

Suggested fix
-def test_cuda_driver_log_captured_via_caplog(caplog):
+def test_cuda_driver_log_captured_via_caplog(caplog, init_cuda):
 
-def test_cuda_driver_log_written_to_file(tmp_path):
+def test_cuda_driver_log_written_to_file(tmp_path, init_cuda):
 
-def test_cuda_driver_log_rebind_logger(caplog):
+def test_cuda_driver_log_rebind_logger(caplog, init_cuda):
 
-def test_cuda_driver_log_level_filtering(caplog):
+def test_cuda_driver_log_level_filtering(caplog, init_cuda):
 
-def test_cuda_driver_log_alert_counter():
+def test_cuda_driver_log_alert_counter(init_cuda):
 
-def test_cuda_driver_log_custom_callback_overrides_default(caplog):
+def test_cuda_driver_log_custom_callback_overrides_default(caplog, init_cuda):


messages = [r.message for r in caplog.records if r.name == logger_name]

assert len(messages) == 2, f"Expected exactly 2 driver log messages, got:\n{messages}"

Check failure on line 38 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_captured_via_caplog AssertionError: Expected exactly 2 driver log messages, got: ['[CUDA Driver] Parameter ordinal must be between 0 and 1', '[CUDA Driver] Returning 101 (CUDA_ERROR_INVALID_DEVICE) from cuDeviceGet', '[CUDA Driver] Parameter ordinal must be between 0 and 1', '[CUDA Driver] Returning 101 (CUDA_ERROR_INVALID_DEVICE) from cuDeviceGet'] assert 4 == 2 + where 4 = len(['[CUDA Driver] Parameter ordinal must be between 0 and 1', '[CUDA Driver] Returning 101 (CUDA_ERROR_INVALID_DEVICE) from cuDeviceGet', '[CUDA Driver] Parameter ordinal must be between 0 and 1', '[CUDA Driver] Returning 101 (CUDA_ERROR_INVALID_DEVICE) from cuDeviceGet'])

Check failure on line 38 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_captured_via_caplog AssertionError: Expected exactly 2 driver log messages, got: [] assert 0 == 2 + where 0 = len([])

Check failure on line 38 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU h100 (x2)

test_cuda_driver_log_captured_via_caplog AssertionError: Expected exactly 2 driver log messages, got: [] assert 0 == 2 + where 0 = len([])

Check failure on line 38 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.15t, CUDA 13.4.2 (wheels), GPU l4

test_cuda_driver_log_captured_via_caplog AssertionError: Expected exactly 2 driver log messages, got: [] assert 0 == 2 + where 0 = len([])
assert "Parameter ordinal must be between 0 and 1" in messages[0]

Check failure on line 39 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 13.4.2 (local), GPU t4 (x2)

test_cuda_driver_log_captured_via_caplog AssertionError: assert 'Parameter ordinal must be between 0 and 1' in '[CUDA Driver] Parameter ordinal must be between 0 and 2'
assert "CUDA_ERROR_INVALID_DEVICE" in messages[1] and "cuDeviceGet" in messages[1]
Comment on lines +38 to +40

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '24,85p' cuda_core/tests/test_cuda_log_bridge.py

Repository: NVIDIA/cuda-python

Length of output: 2482


🏁 Script executed:

rg -n -F -- 'unregister_cuda_error_log' cuda_core/tests/test_cuda_log_bridge.py
sed -n '1,210p' cuda_core/tests/test_cuda_log_bridge.py

Repository: NVIDIA/cuda-python

Length of output: 6606


important: Remove driver-specific log wording and count assumptions.

The driver does not guarantee diagnostic text or callback count. These assertions can fail without a bridge failure.

The post-unregister block already checks forwarding independently of message text with assert not any(r.name == logger_name for r in caplog.records). Keep that assertion and remove the redundant literal-text check.

Suggested fix
-    # cuDeviceGet(9999) is out of range; driver writes two ERROR logs
+    # cuDeviceGet(9999) is out of range; the driver emits error logs
...
-    assert len(messages) == 2, f"Expected exactly 2 driver log messages, got:\n{messages}"
-    assert "Parameter ordinal must be between 0 and 1" in messages[0]
-    assert "CUDA_ERROR_INVALID_DEVICE" in messages[1] and "cuDeviceGet" in messages[1]
+    assert messages, f"Expected forwarded driver log messages, got:\n{messages}"
...
-    assert "Parameter ordinal must be between 0 and 1" not in caplog.text

Apply the same rule to the file, handler-count, and custom-callback checks: assert non-empty forwarded output or >= 1, not exact driver text or exactly two records.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
assert len(messages) == 2, f"Expected exactly 2 driver log messages, got:\n{messages}"
assert "Parameter ordinal must be between 0 and 1" in messages[0]
assert "CUDA_ERROR_INVALID_DEVICE" in messages[1] and "cuDeviceGet" in messages[1]
assert messages, f"Expected forwarded driver log messages, got:\n{messages}"


# After unregistering, driver logs are no longer forwarded
unregister_cuda_error_log()
caplog.clear()
with caplog.at_level(logging.ERROR, logger=logger_name):
driver.cuDeviceGet(9999)
assert not any(r.name == logger_name for r in caplog.records)
assert "Parameter ordinal must be between 0 and 1" not in caplog.text


# Usage 2: redirect driver log to a file
def test_cuda_driver_log_written_to_file(tmp_path):
driver.cuInit(0)

log_file = tmp_path / "cuda_driver.log"
logger_name = "cuda.driver.file_test"
logger_obj = logging.getLogger(logger_name)
logger_obj.setLevel(logging.WARNING)

file_handler = logging.FileHandler(log_file, encoding="utf-8")
file_handler.setLevel(logging.WARNING)
file_handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(name)s: %(message)s"))
logger_obj.addHandler(file_handler)

try:
register_cuda_error_log(logger_obj)

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU rtxpro6000

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU rtxpro6000

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 12.9.1 (wheels), GPU a100

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 12.9.1 (local), GPU v100

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 12.9.1 (local), GPU a100

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU h100

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 12.9.1 (local), GPU t4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 12.9.1 (wheels), GPU t4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.0.2 (wheels), GPU a100

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 12.9.1 (local), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 66 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU t4, wsl

test_cuda_driver_log_written_to_file cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found
driver.cuDeviceGet(9999)
finally:
logger_obj.removeHandler(file_handler)
file_handler.close()

content = log_file.read_text(encoding="utf-8")

assert "Parameter ordinal must be between 0 and 1" in content

Check failure on line 74 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 13.4.2 (local), GPU t4 (x2)

test_cuda_driver_log_written_to_file AssertionError: assert 'Parameter ordinal must be between 0 and 1' in '2026-10-12 22:39:14,822 ERROR cuda.driver.file_test: [CUDA Driver] Parameter ordinal must be between 0 and 2\n2026-10-12 22:39:14,822 ERROR cuda.driver.file_test: [CUDA Driver] Returning 101 (CUDA_ERROR_INVALID_DEVICE) from cuDeviceGet\n'

Check failure on line 74 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_written_to_file AssertionError: assert 'Parameter ordinal must be between 0 and 1' in ''

Check failure on line 74 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU h100 (x2)

test_cuda_driver_log_written_to_file AssertionError: assert 'Parameter ordinal must be between 0 and 1' in '2026-10-12 22:40:39,095 ERROR cuda.driver.file_test: [CUDA Driver] Parameter ordinal must be between 0 and 2\n2026-10-12 22:40:39,096 ERROR cuda.driver.file_test: [CUDA Driver] Returning 101 (CUDA_ERROR_INVALID_DEVICE) from cuDeviceGet\n'

Check failure on line 74 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.15t, CUDA 13.4.2 (wheels), GPU l4

test_cuda_driver_log_written_to_file AssertionError: assert 'Parameter ordinal must be between 0 and 1' in ''
assert "CUDA_ERROR_INVALID_DEVICE" in content and "cuDeviceGet" in content


# Usage 3: register -> unregister -> rebind to another logger
def test_cuda_driver_log_rebind_logger(caplog):
driver.cuInit(0)

name_a, name_b = "cuda.driver.rebind_a", "cuda.driver.rebind_b"

register_cuda_error_log(logging.getLogger(name_a))

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU rtxpro6000

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU rtxpro6000

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 12.9.1 (wheels), GPU a100

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 12.9.1 (local), GPU v100

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 12.9.1 (local), GPU a100

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU h100

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 12.9.1 (local), GPU t4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 12.9.1 (wheels), GPU t4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.0.2 (wheels), GPU a100

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 12.9.1 (local), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 84 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU t4, wsl

test_cuda_driver_log_rebind_logger cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found
with caplog.at_level(logging.ERROR, logger=name_a):
driver.cuDeviceGet(9999)
assert any(r.name == name_a for r in caplog.records)

Check failure on line 87 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_rebind_logger assert False + where False = any(<generator object test_cuda_driver_log_rebind_logger.<locals>.<genexpr> at 0x2a29e494600>)

Check failure on line 87 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_rebind_logger assert False + where False = any(<generator object test_cuda_driver_log_rebind_logger.<locals>.<genexpr> at 0x423a6170700>)

Check failure on line 87 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU h100 (x2)

test_cuda_driver_log_rebind_logger assert False + where False = any(<generator object test_cuda_driver_log_rebind_logger.<locals>.<genexpr> at 0x460541509a0>)

Check failure on line 87 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.15t, CUDA 13.4.2 (wheels), GPU l4

test_cuda_driver_log_rebind_logger assert False + where False = any(<generator object test_cuda_driver_log_rebind_logger.<locals>.<genexpr> at 0x5aaa8140700>)

# Must unregister first to free the driver-side slot, then bind the new logger
unregister_cuda_error_log()
caplog.clear()
register_cuda_error_log(logging.getLogger(name_b))
with caplog.at_level(logging.ERROR, logger=name_b):
driver.cuDeviceGet(9999)

assert not any(r.name == name_a for r in caplog.records)
assert any(r.name == name_b for r in caplog.records)


# Usage 4: the logger's level threshold applies to driver logs too
def test_cuda_driver_log_level_filtering(caplog):
driver.cuInit(0)

logger_name = "cuda.driver.level_test"
register_cuda_error_log(logging.getLogger(logger_name))

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU rtxpro6000

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU rtxpro6000

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 12.9.1 (wheels), GPU a100

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 12.9.1 (local), GPU v100

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 12.9.1 (local), GPU a100

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU h100

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 12.9.1 (local), GPU t4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 12.9.1 (wheels), GPU t4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.0.2 (wheels), GPU a100

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 12.9.1 (local), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 105 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU t4, wsl

test_cuda_driver_log_level_filtering cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

# CRITICAL threshold filters out ERROR-level driver logs
with caplog.at_level(logging.CRITICAL, logger=logger_name):
driver.cuDeviceGet(9999)
assert not any(r.name == logger_name for r in caplog.records)

Check failure on line 110 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_level_filtering assert not True + where True = any(<generator object test_cuda_driver_log_level_filtering.<locals>.<genexpr> at 0x2a2a0410380>)

Check failure on line 110 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_level_filtering assert not True + where True = any(<generator object test_cuda_driver_log_level_filtering.<locals>.<genexpr> at 0x423a6170540>)

Check failure on line 110 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.15t, CUDA 13.4.2 (wheels), GPU l4

test_cuda_driver_log_level_filtering assert not True + where True = any(<generator object test_cuda_driver_log_level_filtering.<locals>.<genexpr> at 0x5aaba3100e0>)

# Lowering to ERROR threshold lets them through
with caplog.at_level(logging.ERROR, logger=logger_name):
driver.cuDeviceGet(9999)
assert any(r.name == logger_name for r in caplog.records)

Check failure on line 115 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU h100 (x2)

test_cuda_driver_log_level_filtering assert False + where False = any(<generator object test_cuda_driver_log_level_filtering.<locals>.<genexpr> at 0x460485b1ea0>)


# Usage 5: custom Handler counts errors, for monitoring/alerting integration
def test_cuda_driver_log_alert_counter():
driver.cuInit(0)

class ErrorCounterHandler(logging.Handler):
def __init__(self):
super().__init__(level=logging.ERROR)
self.count = 0

def emit(self, record):
self.count += 1

logger_obj = logging.getLogger("cuda.driver.alert_test")
counter_handler = ErrorCounterHandler()
logger_obj.addHandler(counter_handler)

try:
register_cuda_error_log(logger_obj)

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU rtxpro6000

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU rtxpro6000

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 12.9.1 (wheels), GPU a100

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 12.9.1 (local), GPU v100

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 12.9.1 (local), GPU a100

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU h100

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 12.9.1 (local), GPU t4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 12.9.1 (wheels), GPU t4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.0.2 (wheels), GPU a100

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 12.9.1 (local), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 135 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU t4, wsl

test_cuda_driver_log_alert_counter cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found
driver.cuDeviceGet(9999)
finally:
logger_obj.removeHandler(counter_handler)

assert counter_handler.count == 2, "Expected exactly 2 ERROR-level driver logs to be counted"

Check failure on line 140 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_alert_counter AssertionError: Expected exactly 2 ERROR-level driver logs to be counted assert 4 == 2 + where 4 = <ErrorCounterHandler (ERROR)>.count

Check failure on line 140 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_alert_counter AssertionError: Expected exactly 2 ERROR-level driver logs to be counted assert 1 == 2 + where 1 = <ErrorCounterHandler (ERROR)>.count

Check failure on line 140 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU h100 (x2)

test_cuda_driver_log_alert_counter AssertionError: Expected exactly 2 ERROR-level driver logs to be counted assert 4 == 2 + where 4 = <ErrorCounterHandler (ERROR)>.count

Check failure on line 140 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.15t, CUDA 13.4.2 (wheels), GPU l4

test_cuda_driver_log_alert_counter AssertionError: Expected exactly 2 ERROR-level driver logs to be counted assert 0 == 2 + where 0 = <ErrorCounterHandler (ERROR)>.count


# Usage 6: use a custom python callback function to change log level and log format
def test_cuda_driver_log_custom_callback_overrides_default(caplog):
driver.cuInit(0)

logger_name = "my_library.cuda-driver"
logger_obj = logging.getLogger(logger_name)

# Log everything as DEBUG, prefixed with the logger name instead of "[CUDA Driver] "
def my_callback(cu_log_level, message):
msg = message.decode("utf-8", errors="replace").rstrip("\n")
logger_obj.debug("%s: %s", logger_obj.name, msg)

register_cuda_error_log(logger_obj, callback=my_callback)

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU rtxpro6000

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU rtxpro6000

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 12.9.1 (wheels), GPU a100

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.10, CUDA 12.9.1 (local), GPU v100

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 12.9.1 (wheels), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 12.9.1 (local), GPU a100

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.13, CUDA 13.0.2 (local), GPU h100

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 12.9.1 (local), GPU t4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.10, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.13, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.11, CUDA 13.0.2 (local), GPU a100

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.12, CUDA 13.0.2 (wheels), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14, CUDA 12.9.1 (wheels), GPU t4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.0.2 (wheels), GPU a100

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 12.9.1 (local), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 13.0.2 (local), GPU l4

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

Check failure on line 155 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.11, CUDA 12.9.1 (wheels), GPU t4, wsl

test_cuda_driver_log_custom_callback_overrides_default cuda.bindings._internal.utils.FunctionNotFoundError: function cuLogsRegisterCallback is not found

# Default WARNING threshold filters out the DEBUG-level driver logs
with caplog.at_level(logging.WARNING, logger=logger_name):
driver.cuDeviceGet(9999)
assert not caplog.records

Check failure on line 160 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-aarch64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_custom_callback_overrides_default assert not [<LogRecord: my_library.cuda-driver, 10, /__w/cuda-python/cuda-python/cuda_core/tests/test_cuda_log_bridge.py, 153, "%s: %s">, <LogRecord: my_library.cuda-driver, 10, /__w/cuda-python/cuda-python/cuda_core/tests/test_cuda_log_bridge.py, 153, "%s: %s">, <LogRecord: my_library.cuda-driver, 10, /__w/cuda-python/cuda-python/cuda_core/tests/test_cuda_log_bridge.py, 153, "%s: %s">] + where [<LogRecord: my_library.cuda-driver, 10, /__w/cuda-python/cuda-python/cuda_core/tests/test_cuda_log_bridge.py, 153, "%s: %s">, <LogRecord: my_library.cuda-driver, 10, /__w/cuda-python/cuda-python/cuda_core/tests/test_cuda_log_bridge.py, 153, "%s: %s">, <LogRecord: my_library.cuda-driver, 10, /__w/cuda-python/cuda-python/cuda_core/tests/test_cuda_log_bridge.py, 153, "%s: %s">] = <_pytest.logging.LogCaptureFixture object at 0x2a29a381550>.records

caplog.clear()

# Lowering the threshold to DEBUG lets them through, with the custom level/format
with caplog.at_level(logging.DEBUG, logger=logger_name):
driver.cuDeviceGet(9999)

assert len(caplog.records) == 2

Check failure on line 168 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU l4

test_cuda_driver_log_custom_callback_overrides_default assert 0 == 2 + where 0 = len([]) + where [] = <_pytest.logging.LogCaptureFixture object at 0x4239c432310>.records

Check failure on line 168 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.14t, CUDA 13.4.2 (local), GPU h100 (x2)

test_cuda_driver_log_custom_callback_overrides_default assert 0 == 2 + where 0 = len([]) + where [] = <_pytest.logging.LogCaptureFixture object at 0x460502321d0>.records

Check failure on line 168 in cuda_core/tests/test_cuda_log_bridge.py

View workflow job for this annotation

GitHub Actions / Test linux-64 / Python 3.15t, CUDA 13.4.2 (wheels), GPU l4

test_cuda_driver_log_custom_callback_overrides_default assert 0 == 2 + where 0 = len([]) + where [] = <_pytest.logging.LogCaptureFixture object at 0x5aab2382310>.records
assert all(r.levelno == logging.DEBUG for r in caplog.records)
assert all(r.message.startswith(f"{logger_name}: ") for r in caplog.records)


# callback must be callable or None, else fail fast
def test_cuda_driver_log_callback_must_be_callable_or_none():
with pytest.raises(TypeError):
register_cuda_error_log(logging.getLogger("cuda.driver.bad_callback_test"), callback="not-callable")
Loading