CUDA with .dll/.so

I have a project in school where we’ll be doing some voxelprocessing (basically some image-processing algorithms for 3d voxels, like blur and sharpening).

I don’t know CUDA at this stage but would like to look at the possibility of using it for this project. I usually work in windows and got very little experience with Linux but for this project we will be developping in Linux.

As I got little to none experience with both Linux and CUDA I’d like to know if it’s possible to build .dll/.so files with both regular c++ and CUDA code and at runtime choose if it’s run on the gpu or in software? This has to be an option as only 5% of the renderfarm got their own graphic cards and it has to run on all the computers.

If some one knows more about this any feedback would be much appreciated. Would be a little problematic if I spend a lot of time getting in to CUDA just to later on find out we can’t use the code :)


That should really be no problem.

I’m no build wizard, but there’s a chance that an NVIDIA CUDA DLL or SO needs to be distributed with your binary to satisfy library dependencies on program startup, but would not be called on non-GPU nodes. Small technicality, which can even be avoided, for sure.

Extra tip -
Also, if you use the Boost libraries for file handling etc., your program will be pretty much identical on Windows and Linux.

CMake + FindCUDA.cmake can build .dll or .so libraries on windows and linux from the same simple project configuration.

You’ll need the CUDA toolkit on all computers (or distribute the the cudart shared library as was suggested), but if your app calls cudaGetDeviceCount and it returns 0, you can then use the CPU path.

Sounds like I can start looking into CUDA.

Thank you both of you for the feedback, and I’ll make sure to look into the boost libraries as well.