Valgrind and CUDA: Are reported leaks real?

Try using cuda-memcheck --leak-check full. Cuda-memcheck is a set of tools that provides similar functionality to Valgrind for CUDA applications. It is installed as part of the CUDA toolkit. You can get more documentation about how to use cuda-memcheck here : http://docs.nvidia.com/cuda/cuda-memcheck/

Note that cuda-memcheck is not a direct replacement for valgrind and can't be used to detect host side memory leaks or buffer overflows.


To add to scarl3tt's answer, this may be overly general for some applications, but if you want to use valgrind while ignoring most of the cuda issues, use the option --suppressions=valgrind-cuda.supp where valgrind-cuda.supp is a file with the following rules:

{
   alloc_libcuda
   Memcheck:Leak
   match-leak-kinds: reachable,possible
   fun:*alloc
   ...
   obj:*libcuda.so*
   ...
}

{
   alloc_libcufft
   Memcheck:Leak
   match-leak-kinds: reachable,possible
   fun:*alloc
   ...
   obj:*libcufft.so*
   ...
}

{
   alloc_libcudaart
   Memcheck:Leak
   match-leak-kinds: reachable,possible
   fun:*alloc
   ...
   obj:*libcudart.so*
   ...
}

It's a known issue that valgrind reports false-positives for a bunch of CUDA stuff. The best way to avoid seeing it would be to use valgrind suppressions, which you can read all about here: http://valgrind.org/docs/manual/manual-core.html#manual-core.suppress

If you want to jumpstart into something a little closer to your specific issue, an interesting post is this one on the Nvidia dev forums. It has a link to a sample suppression rule file. https://devtalk.nvidia.com/default/topic/404607/valgrind-3-4-suppressions-a-little-howto/