How to hook cuda api in the tensorflow?

I am trying to intercept cudaMemcpy, cudaMalloc calls from the python tensorflow library for analysis.
how can I do?


You could use the sanitizer callback API for this purpose. See Sanitizer Api :: Compute Sanitizer Documentation

Thank you for the answer,
Could you share the sanitizer API example when hook the cudaMalloc?

The API tracker displays a similar functionality that could be adapted for your needs: compute-sanitizer-samples/ApiTracker at master · NVIDIA/compute-sanitizer-samples · GitHub