How to get the GPU available memory size or the used memory size used by this process on Ubuntu using cpp? cudaMemGetInfo?

how to get the GPU available memory size or the used memory size used by this process on Ubuntu using cpp?
nvidia-smi can save a process’s video memory size every second to file?
cudaMemGetInfo is precise and enough for this?

I think cudaMemGetInfo() does that.

That isn’t really a CUDA question. I suspect there are multiple methods. The linux utility top for example gives an indication of used process size, so there are probably ways to do it. As you’ve already pointed out, it can vary in time.

I don’t happen to know if it can or can’t, but there is command-line help available for nvidia-smi, and even if it can’t I’m pretty sure you could write a shell script or other means to do that. It’s also possible that the NVML library (used by nvidia-smi) may have some programmatic routines for this. I don’t happen to have a shell script to point you to.

I’m not sure what the criterion are for “precise and enough”. I also don’t know of more precise or exact methods.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.