Skip to content

Report why the host CUDA version could not be read - #2113

Merged
henry118 merged 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/csv-cuda-version-error
Oct 1, 2026
Merged

henry118 merged 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/csv-cuda-version-error

Conversation

@v0ropaev

Copy link
Copy Markdown
Contributor

Description

getEnableCUDACompatHookOptions in pkg/nvcdi/lib-csv.go formats the wrong variable:

ret := l.nvmllib.Init()
if ret != nvml.SUCCESS {
	return nil, fmt.Errorf("failed to initialize NVML: %v", ret)
}
...
hostCUDAVersion, err := l.getCUDAVersionString()
if err != nil {
	return nil, fmt.Errorf("failed to get host CUDA version: %v", ret)
}

ret is assigned once, from Init(), and the check right below it returns early on anything but nvml.SUCCESS. So by the time the CUDA-version call fails, ret is SUCCESS and the message reads

failed to get host CUDA version: SUCCESS

while err, the only thing that says what went wrong, is dropped. getCUDAVersionString returns the nvml.Return from SystemGetCudaDriverVersion as its error, so what is lost is also the value a caller would match on.

Wrapping err with %w matches the rest of the file, which uses %w in nine other places.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Unit tests passing (make test)
  • Lint checks passing (make lint) — golangci-lint is not installed here; gofmt -s -l on the package is clean
  • Test cases are added for new code paths
  • Commits are signed-off — DCO yes, not GPG signed

Testing

TestGetEnableCUDACompatHookOptionsReportsWhyTheVersionFailed drives the function with a mock.Interface whose Init succeeds and whose SystemGetCudaDriverVersion returns ERROR_NOT_SUPPORTED, then asserts the error names that and not SUCCESS. On current main:

Error "failed to get host CUDA version: SUCCESS" does not contain "ERROR_NOT_SUPPORTED"
go test ./pkg/nvcdi/...   all ok
go build ./...            ok

darwin/arm64, Go 1.27.1, no GPU.

getEnableCUDACompatHookOptions formats the error from getCUDAVersionString
with ret, the NVML return of the Init call forty lines up, instead of err.
Init is checked and returns early on anything but SUCCESS, so ret is always
SUCCESS by then and the message reads

  failed to get host CUDA version: SUCCESS

while the only description of the failure, err, is dropped. The wrapped
value is an nvml.Return, so it is also what a caller would match on.

Wrap err with %w, as the rest of the file does.

Signed-off-by: Dmitry Voropaev <dy.voropaev@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@henry118 henry118 self-assigned this Sep 30, 2026
@henry118

henry118 commented Oct 1, 2026

Copy link
Copy Markdown
Member

@v0ropaev can you please cryptographically sign the commit? thanks

@v0ropaev
v0ropaev force-pushed the fix/csv-cuda-version-error branch from 3d5f770 to 1baab56 Compare October 1, 2026 21:25
@v0ropaev

v0ropaev commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Signed this one too, same key. Nothing else changed in the commit.

@henry118

henry118 commented Oct 1, 2026

Copy link
Copy Markdown
Member

/ok to test 1baab56

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 36928533567

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.03%) to 44.636%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 13554
Covered Lines: 6050
Line Coverage: 44.64%
Coverage Strength: 0.45 hits per line

💛 - Coveralls

@henry118
henry118 merged commit cb65efd into NVIDIA:main Oct 1, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants