如何解决如何同时使用推力和 valgrind 来检测内存泄漏?
有没有办法将 CUDA 推力库与 Valgrind 内存泄漏检查器一起使用?
我问的原因是因为这个简单的程序:
#include <thrust/device_vector.h>
int main(){
thrust::device_vector<int> D(5);
assert( D.size() == 5 );
}
编译:
$ /usr/local/cuda-11.1/bin/nvcc device_vector.cu -o device_vector.cu.x
让 Valgrind 相信存在多种可能的内存泄漏。
我知道它们一定是误报,并且 valgrind 不是用来检测 GPU 内存泄漏的,但我想知道是否有标志或标准方法可以使这两种工具协同工作(例如检测 cpu 内存泄漏) .
如果周围有一套标准的 Valgrind 例外,我很乐意使用它们,但我想在玩 wack-a-mole 之前问一下。
$ valgrind ./device_vector.cu.x
==765561== Memcheck,a memory error detector
==765561== copyright (C) 2002-2017,and GNU GPL'd,by Julian Seward et al.
==765561== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==765561== Command: ./device_vector.cu.x
==765561==
==765561== Warning: noted but unhandled ioctl 0x30000001 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: noted but unhandled ioctl 0x27 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: noted but unhandled ioctl 0x25 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: noted but unhandled ioctl 0x37 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: noted but unhandled ioctl 0x17 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: set address range perms: large range [0x200000000,0x300200000) (noaccess)
==765561== Warning: set address range perms: large range [0x681f000,0x2681e000) (noaccess)
==765561== Warning: noted but unhandled ioctl 0x19 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: set address range perms: large range [0x10006000000,0x10106000000) (noaccess)
==765561== Warning: noted but unhandled ioctl 0x49 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: noted but unhandled ioctl 0x21 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: noted but unhandled ioctl 0x1b with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561== Warning: noted but unhandled ioctl 0x44 with no size/direction hints.
==765561== This Could cause spurIoUs value errors to appear.
==765561== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==765561==
==765561== HEAP SUMMARY:
==765561== in use at exit: 6,678,624 bytes in 8,647 blocks
==765561== total heap usage: 11,448 allocs,2,801 frees,40,718,174 bytes allocated
==765561==
==765561== LEAK SUMMARY:
==765561== definitely lost: 0 bytes in 0 blocks
==765561== indirectly lost: 0 bytes in 0 blocks
==765561== possibly lost: 22,216 bytes in 187 blocks
==765561== still reachable: 6,656,408 bytes in 8,460 blocks
==765561== suppressed: 0 bytes in 0 blocks
==765561== Rerun with --leak-check=full to see details of leaked memory
==765561==
==765561== For lists of detected and suppressed errors,rerun with: -s
==765561== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
提到的自述文件 README_MISSING_SYSCALL_OR_IOCTL 对我帮助不大。
注意添加:CUDA 带有一个名为 cuda-memcheck
的 memchecker,它不会报告上述程序中的内存泄漏,但它似乎不能替代 valgrind,因为它不会在一个简单的 cpu 程序中检测到实际的内存泄漏:
#include <thrust/device_vector.h>
int main(){
// thrust::device_vector<int> D(5);
// assert( D.size() == 5 );
// cudaDeviceSynchronize();
std::allocator<int> alloc;
int* p = alloc.allocate(10);
p[0] = 2;
return p[0];
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。