-
Notifications
You must be signed in to change notification settings - Fork 236
Add CUDA version compatibility check #1412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
/ok to test 7ce325c |
7ce325c to
1962e35
Compare
|
/ok to test 1962e35 |
|
8a0d248 to
73e5a43
Compare
|
/ok to test 73e5a43 |
73e5a43 to
ddd92bd
Compare
|
/ok to test ddd92bd |
rparolin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should issue a warning to the user if we can't fetch the driver version.
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
ddd92bd to
62dfcca
Compare
|
/ok to test 62dfcca |
Import warn_if_cuda_major_version_mismatch locally in Device.__new__ after cuInit, using try/except/else pattern instead of module-level import with lambda fallback.
07bf4a4 to
b2083ed
Compare
|
/ok to test b2083ed |
Extract Device.__new__ logic into cdef helper functions: - Device_ensure_cuda_initialized(): cuInit + version check - Device_resolve_device_id(): resolve None to current device or 0 - Device_ensure_tls_devices(): create thread-local singletons Reduces Device.__new__ from ~60 lines to ~12 lines. Helpers placed after Device class following memory module pattern.
a92ed3b to
fdb3a7e
Compare
|
/ok to test fdb3a7e |
|
|
||
| def setup_method(self): | ||
| """Reset the version compatibility check flag before each test.""" | ||
| _version_check._major_version_compatibility_checked = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is effectively going to reset if the version was checked already and after the unit tests executes the check could potentially execute again. Shouldn't we cache the current state and before setting it to false for the unit tests and then restore to its previous value on unit test teardown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone with a dodgy build might get multiple warnings during testing. Not sure it's worth fixing.
|
/ok to test acadb31 |
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