-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
64 lines (54 loc) · 2.15 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
CUMA (CUda Memory Analysis) is a simpel tool I created to detect memory leaks in GPUs.
The idea is to intercept the cudaMalloc and cudaFree and records the memory allocation
information, such as size, pointer, the calling stack and dumps out the un-free-ed
GPU memory in the exit. So far I have only implemented the cudaMalloc/cudaFree pair,
but other memory allocation/free calls can be implemented as well should that be needed.
This library is only needed if the application is getting complicated enough that
you cannot spot the GPU memory leak by reading the code. The usage of the library is
non-instrusive, by using LD_PRELOAD
Sampe code (test.cu) provided:
------------------------------------------------------------------------------
int testfunc()
{
float* A;
float* B;
float* C;
cudaMalloc((void**)&A, sizeof(float)*N);
cudaMalloc((void**)&B, sizeof(float)*N);
cudaMalloc((void**)&C, sizeof(float)*N);
//cudaFree(A);
//cudaFree(B);
cudaFree(C);
return 0;
}
int main()
{
testfunc();
return 0;
}
--------------------------------------------------------------------------------
% LD_PRELOAD=./libcma.so ./test
Summary of GPU memory usage
Memory usage: 3 alloc, 1 free, peak_memory_usage=192, current memory in usage: 128
There are 2 entries in the hash table
entry 0: ptr=0x200100000, size=64. The calling backtrace is
cuda_mem_analysis.c:207 cudaMalloc()
test.cu:13 testfunc()
test.cu:28 main()
??:0 __libc_start_main()
??:0 _start()
entry 1: ptr=0x200100200, size=64. The calling backtrace is
cuda_mem_analysis.c:207 cudaMalloc()
test.cu:14 testfunc()
test.cu:28 main()
??:0 __libc_start_main()
??:0 _start()
-----------------------------------------------------------------------------------
Software requirement:
CUMA needs glib2-devel to compile.
Credit:
The backtrace-symbols.c is from Jeff Muizelaar
(http://opensource.apple.com/source/X11libs/X11libs-40.2/cairo/cairo-1.8.6/util/backtrace-symbols.c)
I modified it slightly to demangle the C++ symbols.
Questions:
Guochun Shi (gshi at ncsa.illinois.edu)