Error trying to compile and run deviceQuery.exe in Visual Studio

I’m trying to install CUDA 9.2 on my Windows 10 machine with a GeForce GT 640M (compute capability 3.0), but I encounter an error when I try to compile and run deviceQuery.exe in Visual Studio Community 2017 (version 15.8.4).

The following is from the command prompt:

CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 30
→ unknown error
Result = FAIL

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.2\1_Utilities\deviceQuery../…/bin/win64/Debug/deviceQuery.exe (process 3888) exited with code 1.

And the following messages are given on the output in Visual Studio:

The thread 0x6cc has exited with code 0 (0x0).
‘deviceQuery.exe’ (Win32): Unloaded ‘C:\Windows\System32\dwmapi.dll’
‘deviceQuery.exe’ (Win32): Unloaded ‘C:\Windows\System32\ole32.dll’
‘deviceQuery.exe’ (Win32): Unloaded ‘C:\Windows\System32\dxgi.dll’
‘deviceQuery.exe’ (Win32): Unloaded ‘C:\Windows\System32\nvapi64.dll’
‘deviceQuery.exe’ (Win32): Unloaded ‘C:\Windows\System32\version.dll’
‘deviceQuery.exe’ (Win32): Unloaded ‘C:\Windows\System32\ws2_32.dll’
‘deviceQuery.exe’ (Win32): Unloaded ‘C:\Windows\System32\nvfatbinaryLoader.dll’
‘deviceQuery.exe’ (Win32): Unloaded ‘C:\Windows\System32\nvcuda.dll’
The thread 0x6b0 has exited with code 1 (0x1).
The thread 0x1c4c has exited with code 1 (0x1).
The thread 0x1e0c has exited with code 1 (0x1).
The program ‘[3888] deviceQuery.exe’ has exited with code 1 (0x1).

Any help would be greatly appreciated, as I could not find anything very similar elsewhere. Cheers!

Can you try to install display driver “http://us.download.nvidia.com/Windows/399.24/399.24-notebook-win10-64bit-international-whql.exe” and try it once again?

Thanks for you help Fancy. Much better, but perhaps not quite there? This is what is shown in cmd:

GPU Device 0: “GeForce GT 640M” with compute capability 3.0

CUDA device [GeForce GT 640M]
time spent executing by the GPU: 33.45
time spent by CPU in CUDA calls: 0.23
CPU executed 4299 iterations while waiting for GPU to finish

And there remains a single error(?) in the output:

‘asyncAPI.exe’ (Win32): Unloaded ‘C:\Windows\System32\dwmapi.dll’

Is this something malfunctioning or am I good to go? Cheers.