cudaGetDeviceCount return uninitialized value

Hi, I am using CUDA 10.1 on a laptop computer with a GTX 1660Ti graphics card and Windows 10 system. My IDE is VS 2019. When I ran cudaGetDeviceCount(&deviceCount), I found the deviceCount value is not initialized (the value was -858993460). And when I ran kernel.cu provided in the CUDA files, I got a “cudaSetDevice failed” message. I wonder why this happened, and how I can fix this. Thank you!

Check the return code for errors.

Thanks for the kind help! I checked the return code, which is 35. I later figured out that that my NVIDIA driver is dated for CUDA 10.1. Updated my driver and everything seems fine now.