Syllo / nvtop

GPU & Accelerator process monitoring for AMD, Apple, Huawei, Intel, NVIDIA and Qualcomm
Other
8.16k stars 292 forks source link

Feature Request: Add batch mode / CLI usage #64

Closed saravanabalagi closed 4 years ago

saravanabalagi commented 4 years ago

Is it possible to add a simple CLI to retrieve usages for logging and/or piping into other programs similar to top? Something like batch_mode -b for top

Example:

nvtop -b -o gpu_mem -o host_mem
# Output
2221MB 2863MB
gothicVI commented 4 years ago

That can already be done using nvidia-smi. You might want to look into that.

NRevathi commented 4 years ago

I tried... but getting errors..

$nvtop -b -o gpu_mem -o host_mem Unhandled error in getopt missing argument $

gothicVI commented 4 years ago

@NRevathi That's not supported (did you even fully read the two posts above yours?). That's actually what this request is about.

You can get the information you're looking for via nvidia-smi.

saravanabalagi commented 4 years ago

@gothicVI, thanks for your reply. I'm aware that nvidia-smi's CLI can be used to get values, and they also offer to format them as csv with or without units like

nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader
# Output
1 %

But how do I get CPU% and Host Mem from what's shown in nvtop? I can do ps -p <pid> but there many problems around that. One, it gives total cpu usage / elapsed time for pid; two, both memory and cpu % will be only for that PID, nvtop on the other hand treats that process and all it's children as one process tree and shows cpu and memory occupied for the process tree.

NRevathi commented 4 years ago

Thanks a lot.

Tried the following command for short-term logging.. I think script is required to capture the data in .csv dynamically and tune the frequency.

$ nvidia-smi --query-gpu=power.draw,temperature.gpu,utilization.gpu,clocks.gr,clocks.sm --format=csv,noheader,nounits -l 1 >> out.csv ^Z [18]+ Stopped nvidia-smi --query-gpu=power.draw,temperature.gpu,utilization.gpu,clocks.gr,clocks.sm --format=csv,noheader,nounits -l 1 >> out.csv $ cat out.csv 3.10, 43, 1, 300, 300 2.92, 43, 1, 300, 300 2.88, 43, 1, 300, 300 2.96, 43, 1, 300, 300 2.89, 43, 0, 300, 300 $

NRevathi commented 4 years ago

I use another tool called CoreFreq to get CPU information.

Thank you.

Syllo commented 4 years ago

Hello,

Thank you for helping @saravanabalagi.

Considering that the nvidia-smi tool provides a CSV interface, I will not implement the same feature myself but would consider a merge request.