How to make a cuda-App "run" on any computer? (with automatic cuda detection) error while

i have a general purpose software, which runs on every computer normally.
there is now a cuda module implemented, and it works good on my computer with geforce 9800gtx+

also there is a function that checks cuda support,
if yes, then some buttons get enabled for cuda functions.
if no, then those buttons show grey (disabled)

my problem is that the program doest not run or computers with other video cards because is dinamycally linking to which comes from nvidia drivers.
so my plan on cuda detection at runtime is failing :(.

is only working on Nvidia hardware :(

any suggestions?

Since you know that cuda can only be run on nvidia cards, why not try checking for the presence of a nvidia card + cuda toolkit during the process of installing this software?

Put all your CUDA code into a shared object (a .so file), define a simple C style API to it (ideally only a few function calls)

Dynamically load the shared object with the dynamic linker (libdl).

If the dynamic linker fails to load your .so file, check the error code (or error string). If it reports that the dynamic linker was unable to load the required dependency, then use the CPU based fallback.

If it loaded successfully, query the dynamic linker for the function entry points and use these instead of your CPU based fallbacks.

If the CPU code has the same C style API you can even swap out the function pointers as needed.


That will work only on pc’s where you have the toolkit installed, won’t it ? In case you have the proper drivers, but don’t have the toolkit, this method fails.

On windows (I’m a windows user) I embed the toolkit dlls into the executable and at runtime I load cuda dynamically and query for devices. If loading succeded (i.e. target machine has the driver) and proper device is found, then just run your cuda code, otherwise either display an error sting to the user or, if you are not lazy, implement a cpu fallback as cbuchner1 suggested.

thanks :) i will look at this, i will answer back with news soon.