Skip to content

getDeviceInfo: different errors for no vs old CUDA driver#6335

Merged
Fedr merged 3 commits into
masterfrom
feature/cudaDriverGetVersion
Jun 27, 2026
Merged

getDeviceInfo: different errors for no vs old CUDA driver#6335
Fedr merged 3 commits into
masterfrom
feature/cudaDriverGetVersion

Conversation

@Fedr

@Fedr Fedr commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Problem

On a computer without any NVIDIA card/driver, cudaGetDeviceCount returns cudaErrorInsufficientDriver"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, before cudaGetDeviceCount(). Unlike cudaGetDeviceCount, it returns cudaSuccess even when no driver is installed — it just reports the version as 0 via its out-parameter. So:

  • driverVersion <= 0no CUDA driver installed at all → reported as a distinct error and we stop early.
  • After that early return, a failure from cudaGetDeviceCount means 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() errors

Situation Message
No CUDA driver installed NVIDIA GPU error: no CUDA driver found
Driver present but too old NVIDIA GPU error: CUDA driver version is insufficient for CUDA runtime version, CUDA driver 11.4
Driver OK, but no GPU NVIDIA GPU error: no capable device found, CUDA driver 12.2

No functional change for machines with a working CUDA GPU.

@Fedr Fedr merged commit f667d4a into master Jun 27, 2026
42 checks passed
@Fedr Fedr deleted the feature/cudaDriverGetVersion branch June 27, 2026 14:07
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.

1 participant