deviceQuery: The CUDA Sample GPU Check
deviceQuery is the classic CUDA sample that enumerates GPUs and prints their properties, proving the CUDA runtime can actually talk to the hardware.
Where nvidia-smi checks the driver, deviceQuery checks the CUDA runtime end to end. If deviceQuery says "Result = PASS", your CUDA stack is genuinely usable.
What it does
deviceQuery calls the CUDA runtime (cudaGetDeviceCount, cudaGetDeviceProperties) to list each GPU and its compute capability, memory, and clock, then prints "Result = PASS" or "FAIL". It is the definitive low-level check that the runtime and driver agree.
Common usage
# build from the CUDA samples (now hosted on GitHub)
cd cuda-samples/Samples/1_Utilities/deviceQuery
make
./deviceQuery
# key line in the output:
# Result = PASSOptions
| Item | What it means |
|---|---|
| Result = PASS | Runtime successfully queried a GPU |
| CUDA Capability Major/Minor | The GPU compute capability (sm_XX) |
| Total amount of global memory | GPU VRAM size |
| Detected N CUDA Capable device(s) | Number of usable GPUs |
In CI
Building and running deviceQuery is a strong smoke test that the toolkit, runtime, and driver all line up before a real workload. The compute capability it prints tells you exactly which -arch=sm_XX to compile for. Since CUDA 11.6 the samples ship on GitHub, not with the toolkit, so clone them.
Common errors in CI
"cudaGetDeviceCount returned 100 -> no CUDA-capable device is detected" and "Result = FAIL" mean the runtime sees no usable GPU: often a container without --gpus all, an empty CUDA_VISIBLE_DEVICES, or a driver/runtime mismatch. "cudaGetDeviceCount returned 35 -> CUDA driver version is insufficient for CUDA runtime version" means the toolkit is newer than the driver supports.