getDeviceInfo: different errors for no vs old CUDA driver#6335
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a computer without any NVIDIA card/driver,
cudaGetDeviceCountreturnscudaErrorInsufficientDriver— "CUDA driver version is insufficient for CUDA runtime version". That's the same error reported when a real NVIDIA GPU is present but its driver is merely too old for our CUDA runtime. So the two very different situations produced an identical, misleading message, and the user couldn't tell whether they need to install a driver or update one.Fix
Query
cudaDriverGetVersion()first, beforecudaGetDeviceCount(). UnlikecudaGetDeviceCount, it returnscudaSuccesseven when no driver is installed — it just reports the version as0via its out-parameter. So:driverVersion <= 0⇒ no CUDA driver installed at all → reported as a distinct error and we stop early.cudaGetDeviceCountmeans the driver is present but unusable (too old, or no device).The installed CUDA driver version is appended to the device-detection error text, so the message is self-diagnosing (e.g. the user can see their driver only supports CUDA 11.4 while the build needs 12.x).
Resulting
getDeviceInfo()errorsNVIDIA GPU error: no CUDA driver foundNVIDIA GPU error: CUDA driver version is insufficient for CUDA runtime version, CUDA driver 11.4NVIDIA GPU error: no capable device found, CUDA driver 12.2No functional change for machines with a working CUDA GPU.