bcc icon indicating copy to clipboard operation
bcc copied to clipboard

Tracing cuda functions

Open sujankh opened this issue 2 years ago • 3 comments

Hi, Is it possible to trace functions in CUDA runtime (libcudart.so) like cudaMalloc? I tried this $ sudo trace-bpfcc 'p:cudart:cudaMalloc "size = %d", arg2', it runs but it does not intercept any cudaMalloc calls from my cuda application. I tried searching around but did not have any luck. Thank you.

sujankh avatar Sep 12 '21 07:09 sujankh

Run ldd on your cuda application to find out which libcudart.so you are linked against, and use the -s option to supply that so for symbol resolution.

chenhengqi avatar Sep 12 '21 16:09 chenhengqi

I encountered the same problem when use sudo python3 /usr/sbin/trace-bpfcc 'p:cudart:cudaMalloc "size = %d", arg2' I want to tracing tensorflow or pytorch gpu training cuda api that coded by python

zxgm avatar Jul 26 '22 10:07 zxgm

I encountered the same problem when use sudo python3 /usr/sbin/trace-bpfcc 'p:cudart:cudaMalloc "size = %d", arg2' I want to tracing tensorflow or pytorch gpu training cuda api that coded by python

The problem already solved, because pytorch runs with the built-in cuda dynamic library instead of the library under the cuda installation path

zxgm avatar Aug 02 '22 02:08 zxgm

Forgot to update here last year: I realized that my binary was statically linked.

I solved my issue by specifying the path to my binary like this:

trace-bpfcc 'p:/path/to/my-binary:cudaMalloc'

and this worked

sujankh avatar Jul 21 '23 22:07 sujankh