I have a program linking against cuda
, cublas
, and cudart
.
Is there a way to deploy it without forcing the users to install the very latest nvidia drivers?
When I just copy the mentioned dlls into the startup path, the program doesn't start and complains about a non-existent procedure in nvcuda.dll
. Even if I supply this one as well, the program behaves strangely. If the most recent drivers are installed, everything works fine.
Related question ... how can I check that cuda is supported (+ up to date) and if this is not the case fallback into my case BLAS/LAPACK? If I provide the dlls the prog. misbehaves, if I don't supply them it might not even start.
Thx!
Did you try not to link against CUDA dlls, but load dynamically and call cudaGetDeviceCount()? Like this:
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
It's inconvenient because you can't just link against cudart or other libraries, but it may allow you to fallback to BLAS without user seeing horrible startup errors. Disclaimer: I didn't test or even compile this code, please let us know if you use it and it works :)
This thread suggests you have to redistribute dlls from your particular version of the CUDA toolkit (e.g. cudart64_40_17.dll), so that's fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With