-
Notifications
You must be signed in to change notification settings - Fork 279
cuda.core: consolidate driver version query functions #2040
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,11 +19,25 @@ | |
| from .conftest import skip_if_nvml_unsupported | ||
|
|
||
|
|
||
| @skip_if_nvml_unsupported | ||
| def test_driver_version(): | ||
| driver_version = system.get_driver_version() | ||
| umd, kmd = system.get_driver_version() | ||
|
|
||
| # UMD: 2-tuple (major, minor), cross-check against cuDriverGetVersion | ||
| assert isinstance(umd, tuple) | ||
| assert len(umd) == 2 | ||
| version = handle_return(driver.cuDriverGetVersion()) | ||
| expected_driver_version = (version // 1000, (version % 1000) // 10) | ||
| assert driver_version == expected_driver_version, "Driver version does not match expected value" | ||
| expected_umd = (version // 1000, (version % 1000) // 10) | ||
| assert umd == expected_umd, "UMD driver version does not match expected value" | ||
|
|
||
| # KMD: 3-tuple (major, minor, patch), or 2-tuple on WSL | ||
| assert isinstance(kmd, tuple) | ||
| assert len(kmd) in (2, 3) | ||
| ver_maj, ver_min, *ver_patch = kmd | ||
| assert 400 <= ver_maj < 1000 | ||
| assert ver_min >= 0 | ||
| if ver_patch: | ||
| assert 0 <= ver_patch[0] <= 99 | ||
|
|
||
|
|
||
| def test_num_devices(): | ||
|
|
@@ -41,28 +55,11 @@ def test_devices(): | |
| assert device.device_id == expected_device.device_id, "Device ID does not match expected value" | ||
|
|
||
|
|
||
| def test_cuda_driver_version(): | ||
| cuda_driver_version = system.get_driver_version_full() | ||
| assert isinstance(cuda_driver_version, tuple) | ||
| assert len(cuda_driver_version) == 3 | ||
|
|
||
| ver_maj, ver_min, ver_patch = cuda_driver_version | ||
| assert ver_maj >= 10 | ||
| assert 0 <= ver_min <= 99 | ||
| assert 0 <= ver_patch <= 9 | ||
|
|
||
|
|
||
| @skip_if_nvml_unsupported | ||
| def test_gpu_driver_version(): | ||
| driver_version = system.get_driver_version(kernel_mode=True) | ||
| assert isinstance(driver_version, tuple) | ||
| assert len(driver_version) in (2, 3) | ||
|
|
||
| (ver_maj, ver_min, *ver_patch) = driver_version | ||
| assert 400 <= ver_maj < 1000 | ||
| assert ver_min >= 0 | ||
| if ver_patch: | ||
| assert 0 <= ver_patch[0] <= 99 | ||
| def test_driver_version_requires_nvml(): | ||
| if system.CUDA_BINDINGS_NVML_IS_COMPATIBLE: | ||
| pytest.skip("NVML is available, cannot test the error path") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More comments explaining why NVML being available prevents testing would be a good trace for the reader.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this test needs a negation for |
||
| with pytest.raises(RuntimeError, match="requires NVML support"): | ||
| system.get_driver_version() | ||
|
|
||
|
|
||
| @skip_if_nvml_unsupported | ||
|
|
||
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.
Why does nvml have to be supported to check the driver version?
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.
Because this PR now uses NVML API calls exclusively.
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.
Yeah, I'd argue there should be more traces to the reader to make that obvious. That coupled with the incorrect header at the top of the file make it difficult to parse.