DLL conflict between version 4.0 and 4.1

Hi, Im having a trouble running a program. Im currently working with GPU type Gefore9800GT and working in Windows OS. Im using nvcc to compile my program. Thing is I have succeed to compile the work, with cudart32_40.dll and it works. However, my coworkers computer only has cudart32_41.dll so he asks me to make the program run regardless to dll version.

By googling I found some solution as following.

typedef cudaError_t (*FnGetDeviceCount )    (   int *   count    ) ;

HMODULE hCuda=LoadLibrary("cudart32_40_17.dll");

if( !hCuda ) return ; // ERROR: cannot load dll, DllMain must have failed because cudart only depends on Kernel dll implicitly. Or cannot find dll in curent directory or in the path.

FnGetDeviceCount fnGetDeviceCount=(FnGetDeviceCount)GetProcAddress(hCuda, "cudaGetDeviceCount");

if( !fnGetDeviceCount) return; // ERROR: cudart has no entry point for cudaGetDeviceCount ?!

int count = 0;

if( cudaSuccess != (*fnGetDeviceCount)(&count) ) return ;// ERROR: we don't wanna use CUDA if even device enumeration fails

if( !count ) return; // FALLBACK: CUDA has no devices, don't try to use it, fallback to some other BLAS

but shouldnt this debugging tool just work to find it there is cudart32_40_17.dll? Is there a way to make such code to find dll from toolkit version higher than 4.0? Thank you.

By linking with the CUDA DLL you are telling your application to locate that DLL at start-up and if it cannot find the DLL it will not work. You can use LoadLibrary, but that is far more complex. That’s just how DLLs work I’m afraid!

The right solution is to link with the oldest version of CUDA you intend to support (so in your case 4.0) and distribute the DLL (i.e. cudart32_40.dll) with your application. The licence agreement specifically allows this for this reason - your end-user (co-worker in this case) needs to have a compatible driver installed, which is 270.81 or later for CUDA 4.0.