runtime test for driver compatibility

I’m wondering if there’s a good way to determine at run-time whether a CUDA-compatible driver is installed.

I want to distribute an app that uses CUDA when it’s present, and falls back to the CPU otherwise. It’s easy enough to check for the device itself, but that check seems to cause a crash if the driver is not installed. Is there an easy solution?

I’m using version 0.9 on win32 and linux32.

Thanks for any help,

Brian

Brian,
you were using the correct approach. If it is crashing, it is a bug that we will fix.

Massimiliano

Ok, I’ve tested this a bit more and had interesting results:

On machine A (win32, with 8800 card, CUDA driver, tools, and SDK installed) everything works fine.

On machine B (win32, no CUDA tools or driver, but cuda.dll cudart.dll and cutil32.dll all present), the device query program works fine. It reports emulation only, which is correct for machine B. However, when I take the device query function and compile it into a dll which I then call from java, it crashes on the dll load. Java reports that “the application is configured incorrectly,” which is not a terribly helpful error message.

The part that confuses me is that the device query program, run as an exe, works just fine on machine B. Also, calling into my device query dll works just fine on machine A. What is it that’s missing on machine B that only affects it when loading a dll?

Brian

Has anybody else attemped a device query from a DLL without the driver/toolkit/sdk installed? I’m still wondering if this problem is on my end or not.

Any help is appreciated!

Brian

Brian,

If your link target (EXE or DLL) is linked against a CUDA import lib, the load will fail if the CUDA DLLs are not present on the system.

If you isolate your CUDA code in a DLL, that DLL is linked against CUDA import lib(s) and at least you can check the return value from LoadLibrary/dlopen to see if the DLL/.so was loaded successfully. If the load fails, you can safely assume that CUDA is not available on the system.

On Windows, you may have to bracket your LoadLibrary call with SetErrorMode() to suppress an end user dialog when the LoadLibrary fails, e.g.:

UINT OldMode = SetErrorMode( SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS );
HMODULE hMod = LoadLibrary( "cufft.dll" );
SetErrorMode( OldMode );

Thanks for the suggestion, but I am loading the DLL through the java native interface, so I can’t control how the load is performed. Also, the CUDA DLLs are present on the system (I copied them there, without actually installing the rest of the driver and tools). Without the CUDA DLLs, I get a DLL not found error, not an application is misconfigured error.

I have not ruled out the JNI loader as the source of the problem. I will keep investigating…

Brian