way of proceeding: check if cuda is possible in runtime


I have a little problem:
I have ported an algorithm from CPU to CUDA. I wrote the whole code with runtime API. The CUDA code is encapsulated in its own dll. Now I have to check if CUDA is available on the current system. So I can use a flag to change between CPU and GPU code.

Can someone please tell me how to check if CUDA is available! I would appreciate it if you can describe the complete way of proceeding.

If it is easier, i could also create another dll, just to check for cuda. But then, how do i have to load them? I am not familiar with delayed import or LoadLibrary().

Because the code is a bit complex i dont want to rewrite it for driver API.

I have read some others threads in this forum but I couldn’t find a satisfying solution.
Or maybe I just don’t get it.


Many thanks in advance.