It is a nuisance making my customers deal with needing the currently correct version of the CUDA runtime DLL. Can the runtime be statically linked to avoid the need for distributing a DLL? I thought I had done it by selecting “Static CUDA runtime library” in the CUDA C / Common section of the project properties, but the DLL is still needed, even with this option enabled.
Which DLL do you mean by “the DLL is still needed” ?
The CUDA runtime can be statically linked. Your visual studio nvcc compile command lines should show evidence of “cudart static” switches somewhere in them.
What CUDA version are you using? What is the exact nvcc commandline used to build and link your application?
I just did some quick experiments using nvcc from CUDA 6.5 on a 64-bit Windows7 system, and from what I see the static CUDA runtime is used by default. I ran a dependency checker on the resulting executable, and no dependency on CUDA-related DLLs is reported.
I’m using CUDA 6.5, and the NVCC command line does include -cudart static. But if I start the program on a computer that does not have my development environment installed, the program fails with a message saying that it can’t find cudart64_65.dll. I copy that dll to the computer and the program runs perfectly.
At least now I know that it SHOULD work. Now if only I can figure out WHY it doesn’t!
Thanks for any advice!
You might want to scrutinize the nvcc commandline(s) in detail. Pointy-clicky IDEs (as well as tools like CMake) have a tendency to construct compiler and linker commandlines that do not correspond to what the programmer intended, and of course the relevant setting to turn off the unwanted elements is always hidden in some obscure corner :-)
I did a cross check by hiding cudart64_65.dll and my little CUDA test app compiled with CUDA 6.5 at nvcc default settings still executes fine. I would suggest using a dependency checker to find out which component(s) of your app depend(s) on cudart64_65.dll. It may be the case that your app includes a library which in turn has a dependency on cudart64_65.dll.
That was great advice, but unfortunately the dependency is at the root level - the executable itself. Also, I am not using any other CUDA libraries.
I definitely verified that “-cudart static” is on the nvcc command line at build time. Also, if I go to the Visual Studio linker page and remove CUDART.LIB as a linker input, the build fails with a boatload of unresolved references. So it’s relying on the static library. So where the heck is that cudart64_65.dll dependency coming from??? Sigh. This is so frustrating.
How complex is the application? Can you simply build with nvcc from the command prompt, not through Visual Studio?
If you have not resolved this issue I believe I have your answer. I encountered the same issue and fixed it by linking to the cudart_static.lib rather than cudart.lib. Just did that through Visual Studio, with no changes to nvcc.
Thanks slarkin712! That’s what exactly the problem is.