Hey guys, how are you dealing with support for both CUDA and OpenCL on different cards? In my executable, I want to use CUDA if it’s supported and use OpenCL if it’s not (i.e. AMD cards). The catch is that for machines that don’t have a nvcuda.dll (non-NVIDIA), I get the dll not found window on startup. Is there some way to detect if CUDA is supported, and only then dynamically link nvcuda.dll? Ideally I’d just call cuInit(), and if the dll doesn’t exist, it would just return false and I’d be on my way. Thanks!
Really? Has no one had to deal with this issue? Anyone? Bueller? Anyone??
Look at the dynlink folder in the SDK.
Driver API : cuda_drvapi_dynlink.h (call cuDriverAPIdynload())
Runtime API : cuda_runtime_api_dynlink.h (call cudaRuntimeDynload())
Thanks! One follow up though: How do you change it for 64-bit? The 32 bit version works fine. Obviously, to use the 64-bit api I have to tweak the prototypes. But how do you load the correct functions? Do you have to load from a different dll, or is it the same dll but you have to enter a different value into GetProcAddress()?
In 64-bit, it loads the same DLL name from a different path, so it ends up loading 64-bit versions of the same functions. There is no need to change any code.
Is this still working with cuda 3.2?
I’m trying to use the cuda_runtime_api_dynlink.h from the sdk.
I changed my header to:
#if defined(CUDA_STATIC_LINKING) #include <cuda.h> #include <cuda_runtime_api.h> #else // using CUDA runtime dynamic linking instead of static linking #include "cuda_runtime_api_dynlink.h" #endif
But I’m now getting compile errors, it seems some functions are missing in the h file (btw, it says CUDART_VERSION=2.1)