When using TensorFlow to run deep learning, there is often a lack of memory, so we want to be able to view the GPU usage at any time. If you are the NVIDIA GPU, you can do this at the command line with just one line of command.
1. Show current GPU usage
Nvidia comes with a NVIDIA-SMI command-line tool that displays video memory usage:
Nvidia-smi
Output:
2. Periodic output of GPU usage
But sometimes we want to not only know the GPU usage at that fixed time, we want to keep track of it, and we want to output it periodically, such as updating the display every 10s. This is the time to use the Watch command to periodically execute the nvidia-smi command.
Learn about Watch's features:
Whatis Watch Watch (1) -Execute a program periodically, showing output fullscreen
Function: Periodically executes a command and displays the output.
The basic usage of watch is:
Watch [options] command
The most commonly used parameter is-n, which specifies the number of seconds to execute once per command.
Monitor Memory: We set the video memory to be displayed every 10s:
Ten Nvidia-smi
Shown below:
So, just open this command-line window, you can refresh every 10 seconds, is it convenient?
If we want to perform other command-line operations periodically, then you can simply replace the back nvidia-smi, so Cool!
52649174
Monitor Nvidia's GPU usage under Linux (RPM)