Small cross-check utility that detects whether the current Windows machine has an NVIDIA GPU and whether CUDA is available.
This repository contains a tiny .NET console app that performs two checks:
- Detects presence of an NVIDIA graphics adapter by querying WMI's Win32_VideoController and looking for "nvidia" in the device name.
- Checks whether NVIDIA CUDA is available by attempting to call a small subset of the CUDA Driver API exported by
nvcuda.dll.
The tool is useful for CI checks, quick local diagnostics, or scripting where you only need a boolean answer about NVIDIA/CUDA availability.
- GpuChecker.HasNvidiaGpu(): Queries WMI (
Win32_VideoController) and returns true if any video controller's Name contains "nvidia" (case-insensitive). - GpuChecker.IsCudaAvailable(): Tries to P/Invoke
cuInit(0)andcuDeviceGetCountfromnvcuda.dll. If the DLL is missing or calls fail, the method returns false. If the calls succeed and report at least one device, it returns true.
- Windows (the project uses WMI via
System.Managementand P/Invoke againstnvcuda.dll). - .NET 9 (the project targets net9.0 in the current build artifacts). Install the appropriate .NET SDK from https://dotnet.microsoft.com if you need it.
- If you want CUDA detection to succeed, the NVIDIA driver with the CUDA driver (nvcuda.dll) must be installed and accessible.
CheckForGraphicCard/Program.cs— the console app entrypoint that calls the checks and prints one of three user-friendly messages:- "NVIDIA GPU with CUDA support detected!"
- "NVIDIA GPU found, but CUDA not available."
- "No NVIDIA GPU detected."
CheckForGraphicCard/GpuChecker.cs— contains the two detection methods described above.CheckForGraphicCard.csproj— project file for the console app (targets .NET 9).
Open a terminal (PowerShell) and run the following from the repo root:
dotnet build
dotnet run --project "CheckForGraphicCard\CheckForGraphicCard.csproj"Expected output is one of the three messages listed above.
- The NVIDIA GPU detection is based on the adapter name exposed through WMI. Some virtualized or manufacturer-specific adapters might not contain the literal string "nvidia" and therefore won't be detected.
- CUDA detection depends on the presence and availability of
nvcuda.dll(the CUDA driver API). If the DLL is missing, the check returns false. Having the CUDA toolkit installed is not required for the detection; the GPU driver with the CUDA driver is required. - The code P/Invokes into native code and uses WMI. Run the app with appropriate privileges if Windows security settings prevent WMI access.
- This project is intentionally minimal and dependency-free; it does not enumerate CUDA device properties or versions. It only tells you whether a CUDA driver and at least one CUDA device are present.