Uh oh!
There was an error while loading. Please reload this page.
Add CUDA version compatibility check - #1412
Conversation
Andy-Jost
commented
Dec 18, 2025
/ok to test 7ce325c07b559e9a66472f5ba7a99fe980e17c09 |
7ce325c to
1962e35CompareAndy-Jost
commented
Dec 18, 2025
/ok to test 1962e351a233d65f2288fd6d16a43f0b0b75d6ad |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
| @@ -9,6 +9,8 @@ Runtime Environment Variables | |||
| - ``CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM`` : When set to 1, the default stream is the per-thread default stream. When set to 0, the default stream is the legacy default stream. This defaults to 0, for the legacy default stream. See `Stream Synchronization Behavior <https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html>`_ for an explanation of the legacy and per-thread default streams. | |||
| - ``CUDA_PYTHON_DISABLE_VERSION_CHECK`` : When set to 1, suppresses the warning that is issued when ``cuda.core`` detects that ``cuda-bindings`` was compiled against a newer CUDA major version than the installed driver supports. This warning helps identify version mismatches that may cause features to not work correctly. | |||
There was a problem hiding this comment.
This env var is added to cuda-bindings docs, but the actual change is made to cuda-core? Can we move them to the right place?
Actually, thinking about this we probably should do this check in cuda-bindings instead of cuda-core, since it's what actually matters. The question is if there is a good place that would allow lazy-init. Remember, both cuda-core and cuda-bindings can be installed and imported on CPU-only machines, without driver or a physical GPU installed. I can't think of an obvious solution off top of my head.
There was a problem hiding this comment.
What about cuInit? That seems like a logical place for the version check, though the change might be more complex.
There was a problem hiding this comment.
As discussed, cuda-bindings provides the check; cuda-core invokes it. Other consumers of cuda-bindings can also invoke the check.
Uh oh!
There was an error while loading. Please reload this page.
8a0d248 to
73e5a43CompareAndy-Jost
commented
Dec 19, 2025
/ok to test 73e5a4379fad3392c24499e245a521c86c53db42 |
73e5a43 to
ddd92bdCompareAndy-Jost
commented
Dec 19, 2025
/ok to test ddd92bd |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
rparolin
left a comment
There was a problem hiding this comment.
We should issue a warning to the user if we can't fetch the driver version.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Add warn_if_cuda_major_version_mismatch() to cuda-bindings that warns when cuda-bindings was compiled for a newer CUDA major version than the installed driver supports. Called by cuda.core on first Device access.
# Conflicts: # cuda_core/pixi.lock
Uh oh!
There was an error while loading. Please reload this page.
Andy-Jost
commented
Jan 9, 2026
/ok to test acadb31 |
Integrate RAII handles architecture from main while preserving the version compatibility check feature. Resolved conflict in _device.pyx by keeping the refactored helper functions and updating field names to match RAII object structure.
acadb31 to
3a5c210CompareAndy-Jost
commented
Jan 13, 2026
/ok to test 3a5c210 |
Andy-Jost
commented
Jan 14, 2026
/ok to test 424a113 |
Andy-Jost
commented
Jan 14, 2026
/ok to test 6071609 |
Uh oh!
There was an error while loading. Please reload this page.
| - ``CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM`` : When set to 1, the default stream is the per-thread default stream. When set to 0, the default stream is the legacy default stream. This defaults to 0, for the legacy default stream. See `Stream Synchronization Behavior <https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html>`_ for an explanation of the legacy and per-thread default streams. | ||
| - ``CUDA_PYTHON_DISABLE_MAJOR_VERSION_WARNING`` : When set to 1, suppresses warnings about CUDA major version mismatches between ``cuda-bindings`` and the installed driver. |
There was a problem hiding this comment.
TBH I am not sure if this env var is really useful, because the added API is entirely opt-in?
There was a problem hiding this comment.
The version check can be triggered indirectly from the end user's POV. For example, by using cuda-core. Without this, each library that calls the version-check function would need its own opt-out, and users might need to set them all. To me it makes sense to place the opt-out alongside the implementation and there is little/no cost.
There was a problem hiding this comment.
I insist that this is useless because this is listed in the cuda-bindings docs, not cuda-core. But cuda-bindings does not call this function anywhere, whereas cuda-core users don't necessarily look at cuda-bindings docs. Can we please create a new environment_variables.rst for cuda-core if we think this is helpful there?
There was a problem hiding this comment.
Even better: Document this env var in both docs.
There was a problem hiding this comment.
Good point. The same argument applies to all cuda.bindings runtime variables, so I:
- duplicated both
CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAMandCUDA_PYTHON_DISABLE_MAJOR_VERSION_WARNINGin the cuda.core documentation; and - added a note referencing the cuda.bindings runtime variables and linking to the relevant documentation page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Andy-Jost
commented
Jan 14, 2026
/ok to test 96532b226 |
96532b2 to
973af9bCompareAndy-Jost
commented
Jan 14, 2026
/ok to test 973af9b7a |
973af9b to
27732f2CompareReplace setup_method/teardown_method with a pytest fixture that uses monkeypatch to properly save and restore the original value of _major_version_compatibility_checked after each test. Minor change to Cython cdef inline helper function signature.
27732f2 to
7f23b08CompareAndy-Jost
commented
Jan 14, 2026
/ok to test 7f23b08 |
Uh oh!
There was an error while loading. Please reload this page.
Document runtime environment variables that affect cuda.core behavior: - CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM - CUDA_PYTHON_DISABLE_MAJOR_VERSION_WARNING Include note linking to cuda-bindings environment variables documentation.
Andy-Jost
commented
Jan 23, 2026
/ok to test a368e0f |
Uh oh!
There was an error while loading. Please reload this page.
|
Summary
Adds a version compatibility check that warns users when cuda-bindings was compiled against a newer CUDA major version than the installed driver supports.
Changes
cuda-bindings
check_cuda_version_compatibility()function incuda/bindings/utils/_version_check.pyCUDA_VERSIONvs runtimecuDriverGetVersion()cuda.bindings.utilstests/test_version_check.pycuda-core
Device.__new__callscheck_cuda_version_compatibility()aftercuInitsucceedscuda.bindings.utilsRationale
When cuda-bindings is built against CUDA 13 headers but the user's driver only supports CUDA 12, many features will silently fail or behave unexpectedly. This check provides early, clear feedback:
Design
cuda.bindings.utilssince it checks cuda-bindings' compile-time versionDevicefirst triggers CUDA initializationCUDA_PYTHON_DISABLE_VERSION_CHECK=1to disableFuture Work
We could not find a suitable place to invoke the version check automatically within cuda-bindings itself (e.g., hooking into
cuInit), so the check is currently triggered by cuda-core. This may be revisited in the future.Test Coverage
7 tests in cuda-bindings covering:
Related Work