detect cuda2 vs cuda1

Is there any way to detect the presence of CUDA 2 vs CUDA 1.1 and CUDA 1.0?
Will be a good idea to include a function to see if CUDA 2 is present… or CUDA 1.1… or CUDA 1.0.


Yes True! Nice idea!!

If by “detect” you mean determine in your code what SDK you’re compiling against, you can get this by examining the preprocessor constant CUDART_VERSION (defined in <cuda.h> (or <cutil.h>?). Since I think there is some linker compatibility, you may also want to determine what version of the library you are linked with. Not sure what symbols exist to help out there.


#if CUDART_VERSION >= 2000
CUT_DEVICE_INIT(argc, argv);

Hehe, I was referring to the runtime installed. For example, imagine an user has the FW 175.16 … and CUDA 2 is not supported by them(it’s only using the 174.55 beta)… Currently all I can do is to call cudaSetDevice() and show a “Cannot initialize CUDA” on cudaError_t==cudaErrorInitializationError… I would like to show something like “Sorry, your graphics drivers support only CUDA 1.1 and this program needs CUDA 2.0”.

As a hack, I could see the nvcuda.dll resource description/size/CRC… but if NVIDIA patches it… weird things gonna happen hehe! :nukeclap:

One way would be to do a run-time link, ie: LoadLibrary(“nvcuda.dll”) and use GetProcAddress() to check for a function that is only available in CUDA 2.0.

And if NVIDIA decides to rename the nvcuda.dll to nvcuda2.dll one day?

I think we need to add a function to the CUDA SDK for this, seriously.

I agree an API call to get the version could be useful. But in that case, your program will be unable to find the DLL in any case, and an API function won’t help either :)

Not really… the cudaGetVersion() detection routine should avoid any DLL call… for example, could be an entry into the registry… or to test the existence of a specific file… and should be statically-linked(or inlined) if possible.