cudaGetDeviceCount fails to detect device in Windows service


when I try to use CUDA within a Windows service, on some machines it works perfectly fine whereas on others cudaGetDeviceCount returns error 100 and fails to detect any graphics card. I’m not able to detect any regularity that would explain this as I’ve seen systems with RTX A4000 where it runs without errors, but I’ve also seen systems with RTX A4000 where it doesn’t. Recently I came across a system with GTX 1650 where it failed, but I’ve also seen lots of systems with GTX 1650 where it works.

Interestingly enough, I noticed that on systems where it fails, the service will detect the graphics cards when I login to an interactive user session and manually restart the Windows service from the services manager.

However, I would like to run a Windows service for CUDA computations which starts and detects the graphics cards without having any user to login to the system. As it works perfectly well in the majority of cases, I don’t think that this is impossible. Can someone share insights on the prerequisites that make this possible?

If I raised this question in the wrong topic, could someone please move it to a more appropriate location? Or does nobody have any clue?