16

When i use nvidia-smi -l 60 for example, i was asking to myself if :

  • the information given is a snapshot at the time it's used each 60 seconds
  • the information given is the average between the time and the time +/- 60 seconds

Do you know the answer ? i couldn't find it yet.

Thank you.

Vincent Rossignol
  • 215
  • 1
  • 2
  • 8

1 Answers1

41

The -l options performs polling on nvidia-smi every given seconds (-lms if you want to perform every given milliseconds). So basically yes it's a snapshot every given amount of time.

Actually if you just want to monitor it, you could do the same with the watch utility (which is the standard way of polling on a shell script). This will display the nvidia-smi output and update it every 1 second: watch -n 1 nvidia-smi

If you want to redirect it to some file (and eventually filter it if you are interested in some specific metric) you could also build a short shell script to do that such as:

while true; do nvidia-smi | tee -a logfile && sleep 2; done

lopisan
  • 7,720
  • 3
  • 37
  • 45
Emilien
  • 2,385
  • 16
  • 24
  • 2
    Well, i'm interested to collect on average on this interval loop, not a snapshot. What's the point between using -l or a watch ? – Vincent Rossignol Mar 10 '16 at 10:06
  • 1
    It's the same, but if the utility does not have this feature that's how you would do it. If you actually want an average value you need to poll more frequently (for instance every second) and then do the average. – Emilien Mar 10 '16 at 10:10
  • 2
    To get updates in milliseconds, use `-lms`. For example, to update 20 times per second: `nvidia-smi -lms 50` – automorphic Mar 16 '18 at 00:33
  • Using `-lms` just repeats the output in the console, but does not replace the output, so that `-lms 50` is useless for me on Ubuntu 18.04. The watch option works fine. – phi Mar 08 '21 at 09:25